Skip to content

Commit

Permalink
fix(clients): populate message field when parsing errors (#3995)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Sep 28, 2022
1 parent 3ed75ec commit 02e47f1
Show file tree
Hide file tree
Showing 328 changed files with 14,218 additions and 12,260 deletions.
62 changes: 34 additions & 28 deletions clients/client-accessanalyzer/src/protocols/Aws_restJson1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ const deserializeAws_restJson1ApplyArchiveRuleCommandError = async (
): Promise<ApplyArchiveRuleCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -998,7 +998,7 @@ const deserializeAws_restJson1CancelPolicyGenerationCommandError = async (
): Promise<CancelPolicyGenerationCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1048,7 +1048,7 @@ const deserializeAws_restJson1CreateAccessPreviewCommandError = async (
): Promise<CreateAccessPreviewCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1107,7 +1107,7 @@ const deserializeAws_restJson1CreateAnalyzerCommandError = async (
): Promise<CreateAnalyzerCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1160,7 +1160,7 @@ const deserializeAws_restJson1CreateArchiveRuleCommandError = async (
): Promise<CreateArchiveRuleCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1216,7 +1216,7 @@ const deserializeAws_restJson1DeleteAnalyzerCommandError = async (
): Promise<DeleteAnalyzerCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1266,7 +1266,7 @@ const deserializeAws_restJson1DeleteArchiveRuleCommandError = async (
): Promise<DeleteArchiveRuleCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1319,7 +1319,7 @@ const deserializeAws_restJson1GetAccessPreviewCommandError = async (
): Promise<GetAccessPreviewCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1372,7 +1372,7 @@ const deserializeAws_restJson1GetAnalyzedResourceCommandError = async (
): Promise<GetAnalyzedResourceCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1425,7 +1425,7 @@ const deserializeAws_restJson1GetAnalyzerCommandError = async (
): Promise<GetAnalyzerCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1478,7 +1478,7 @@ const deserializeAws_restJson1GetArchiveRuleCommandError = async (
): Promise<GetArchiveRuleCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1531,7 +1531,7 @@ const deserializeAws_restJson1GetFindingCommandError = async (
): Promise<GetFindingCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1587,7 +1587,7 @@ const deserializeAws_restJson1GetGeneratedPolicyCommandError = async (
): Promise<GetGeneratedPolicyCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1640,7 +1640,7 @@ const deserializeAws_restJson1ListAccessPreviewFindingsCommandError = async (
): Promise<ListAccessPreviewFindingsCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1699,7 +1699,7 @@ const deserializeAws_restJson1ListAccessPreviewsCommandError = async (
): Promise<ListAccessPreviewsCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1755,7 +1755,7 @@ const deserializeAws_restJson1ListAnalyzedResourcesCommandError = async (
): Promise<ListAnalyzedResourcesCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1811,7 +1811,7 @@ const deserializeAws_restJson1ListAnalyzersCommandError = async (
): Promise<ListAnalyzersCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1864,7 +1864,7 @@ const deserializeAws_restJson1ListArchiveRulesCommandError = async (
): Promise<ListArchiveRulesCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1917,7 +1917,7 @@ const deserializeAws_restJson1ListFindingsCommandError = async (
): Promise<ListFindingsCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -1973,7 +1973,7 @@ const deserializeAws_restJson1ListPolicyGenerationsCommandError = async (
): Promise<ListPolicyGenerationsCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -2023,7 +2023,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async (
): Promise<ListTagsForResourceCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -2076,7 +2076,7 @@ const deserializeAws_restJson1StartPolicyGenerationCommandError = async (
): Promise<StartPolicyGenerationCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -2129,7 +2129,7 @@ const deserializeAws_restJson1StartResourceScanCommandError = async (
): Promise<StartResourceScanCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -2179,7 +2179,7 @@ const deserializeAws_restJson1TagResourceCommandError = async (
): Promise<TagResourceCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -2229,7 +2229,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async (
): Promise<UntagResourceCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -2279,7 +2279,7 @@ const deserializeAws_restJson1UpdateArchiveRuleCommandError = async (
): Promise<UpdateArchiveRuleCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -2329,7 +2329,7 @@ const deserializeAws_restJson1UpdateFindingsCommandError = async (
): Promise<UpdateFindingsCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -2385,7 +2385,7 @@ const deserializeAws_restJson1ValidatePolicyCommandError = async (
): Promise<ValidatePolicyCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -3835,6 +3835,12 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
return {};
});

const parseErrorBody = (errorBody: any, context: __SerdeContext): any => {
const value = parseBody(errorBody, context);
value.message = value.message ?? value.Message;
return value;
};

/**
* Load an error code for the aws.rest-json-1.1 protocol.
*/
Expand Down
16 changes: 11 additions & 5 deletions clients/client-account/src/protocols/Aws_restJson1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const deserializeAws_restJson1DeleteAlternateContactCommandError = async (
): Promise<DeleteAlternateContactCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -249,7 +249,7 @@ const deserializeAws_restJson1GetAlternateContactCommandError = async (
): Promise<GetAlternateContactCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -302,7 +302,7 @@ const deserializeAws_restJson1GetContactInformationCommandError = async (
): Promise<GetContactInformationCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -352,7 +352,7 @@ const deserializeAws_restJson1PutAlternateContactCommandError = async (
): Promise<PutAlternateContactCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -399,7 +399,7 @@ const deserializeAws_restJson1PutContactInformationCommandError = async (
): Promise<PutContactInformationCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseBody(output.body, context),
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
Expand Down Expand Up @@ -585,6 +585,12 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
return {};
});

const parseErrorBody = (errorBody: any, context: __SerdeContext): any => {
const value = parseBody(errorBody, context);
value.message = value.message ?? value.Message;
return value;
};

/**
* Load an error code for the aws.rest-json-1.1 protocol.
*/
Expand Down
Loading

0 comments on commit 02e47f1

Please sign in to comment.