Skip to content

Commit

Permalink
feat: unified error dispatcher in protocols (#5756)
Browse files Browse the repository at this point in the history
* feat: error serde

* chore: update codegen diff

* chore: update smithy hash with small fix

* chore: update codegen w/ as never
  • Loading branch information
kuhe committed Feb 5, 2024
1 parent 2da1b6c commit 0872087
Show file tree
Hide file tree
Showing 385 changed files with 83,018 additions and 609,382 deletions.
1,566 changes: 194 additions & 1,372 deletions clients/client-accessanalyzer/src/protocols/Aws_restJson1.ts

Large diffs are not rendered by default.

328 changes: 18 additions & 310 deletions clients/client-account/src/protocols/Aws_restJson1.ts

Large diffs are not rendered by default.

1,004 changes: 111 additions & 893 deletions clients/client-acm-pca/src/protocols/Aws_json1_1.ts

Large diffs are not rendered by default.

580 changes: 60 additions & 520 deletions clients/client-acm/src/protocols/Aws_json1_1.ts

Large diffs are not rendered by default.

3,285 changes: 412 additions & 2,873 deletions clients/client-alexa-for-business/src/protocols/Aws_json1_1.ts

Large diffs are not rendered by default.

1,254 changes: 137 additions & 1,117 deletions clients/client-amp/src/protocols/Aws_restJson1.ts

Large diffs are not rendered by default.

1,434 changes: 69 additions & 1,365 deletions clients/client-amplify/src/protocols/Aws_restJson1.ts

Large diffs are not rendered by default.

1,187 changes: 67 additions & 1,120 deletions clients/client-amplifybackend/src/protocols/Aws_restJson1.ts

Large diffs are not rendered by default.

877 changes: 71 additions & 806 deletions clients/client-amplifyuibuilder/src/protocols/Aws_restJson1.ts

Large diffs are not rendered by default.

5,392 changes: 429 additions & 4,963 deletions clients/client-api-gateway/src/protocols/Aws_restJson1.ts

Large diffs are not rendered by default.

Expand Up @@ -93,7 +93,7 @@ export const de_DeleteConnectionCommand = async (
context: __SerdeContext
): Promise<DeleteConnectionCommandOutput> => {
if (output.statusCode !== 204 && output.statusCode >= 300) {
return de_DeleteConnectionCommandError(output, context);
return de_CommandError(output, context);
}
const contents: any = map({
$metadata: deserializeMetadata(output),
Expand All @@ -102,38 +102,6 @@ export const de_DeleteConnectionCommand = async (
return contents;
};

/**
* deserializeAws_restJson1DeleteConnectionCommandError
*/
const de_DeleteConnectionCommandError = async (
output: __HttpResponse,
context: __SerdeContext
): Promise<DeleteConnectionCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
case "ForbiddenException":
case "com.amazonaws.apigatewaymanagementapi#ForbiddenException":
throw await de_ForbiddenExceptionRes(parsedOutput, context);
case "GoneException":
case "com.amazonaws.apigatewaymanagementapi#GoneException":
throw await de_GoneExceptionRes(parsedOutput, context);
case "LimitExceededException":
case "com.amazonaws.apigatewaymanagementapi#LimitExceededException":
throw await de_LimitExceededExceptionRes(parsedOutput, context);
default:
const parsedBody = parsedOutput.body;
return throwDefaultError({
output,
parsedBody,
errorCode,
});
}
};

/**
* deserializeAws_restJson1GetConnectionCommand
*/
Expand All @@ -142,7 +110,7 @@ export const de_GetConnectionCommand = async (
context: __SerdeContext
): Promise<GetConnectionCommandOutput> => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_GetConnectionCommandError(output, context);
return de_CommandError(output, context);
}
const contents: any = map({
$metadata: deserializeMetadata(output),
Expand All @@ -157,38 +125,6 @@ export const de_GetConnectionCommand = async (
return contents;
};

/**
* deserializeAws_restJson1GetConnectionCommandError
*/
const de_GetConnectionCommandError = async (
output: __HttpResponse,
context: __SerdeContext
): Promise<GetConnectionCommandOutput> => {
const parsedOutput: any = {
...output,
body: await parseErrorBody(output.body, context),
};
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
switch (errorCode) {
case "ForbiddenException":
case "com.amazonaws.apigatewaymanagementapi#ForbiddenException":
throw await de_ForbiddenExceptionRes(parsedOutput, context);
case "GoneException":
case "com.amazonaws.apigatewaymanagementapi#GoneException":
throw await de_GoneExceptionRes(parsedOutput, context);
case "LimitExceededException":
case "com.amazonaws.apigatewaymanagementapi#LimitExceededException":
throw await de_LimitExceededExceptionRes(parsedOutput, context);
default:
const parsedBody = parsedOutput.body;
return throwDefaultError({
output,
parsedBody,
errorCode,
});
}
};

/**
* deserializeAws_restJson1PostToConnectionCommand
*/
Expand All @@ -197,7 +133,7 @@ export const de_PostToConnectionCommand = async (
context: __SerdeContext
): Promise<PostToConnectionCommandOutput> => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_PostToConnectionCommandError(output, context);
return de_CommandError(output, context);
}
const contents: any = map({
$metadata: deserializeMetadata(output),
Expand All @@ -207,12 +143,9 @@ export const de_PostToConnectionCommand = async (
};

/**
* deserializeAws_restJson1PostToConnectionCommandError
* deserialize_Aws_restJson1CommandError
*/
const de_PostToConnectionCommandError = async (
output: __HttpResponse,
context: __SerdeContext
): Promise<PostToConnectionCommandOutput> => {
const de_CommandError = async (output: __HttpResponse, context: __SerdeContext): Promise<never> => {
const parsedOutput: any = {
...output,
body: await parseErrorBody(output.body, context),
Expand All @@ -237,7 +170,7 @@ const de_PostToConnectionCommandError = async (
output,
parsedBody,
errorCode,
});
}) as never;
}
};

Expand Down

0 comments on commit 0872087

Please sign in to comment.