diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructureGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructureGenerator.java index e7e50f88d9b..24de405260e 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructureGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructureGenerator.java @@ -174,8 +174,9 @@ private void renderStructureNamespace(StructuredMemberWriter structuredMemberWri } /** - * Error structures generate interfaces that extend from SmithyException - * and add the appropriate fault property. + * Error structures generate classes that extend from ServiceException + * (SmithyException is case of server SDK), and add the appropriate fault + * property. * *
Given the following Smithy structure: * @@ -192,8 +193,10 @@ private void renderStructureNamespace(StructuredMemberWriter structuredMemberWri *
The following TypeScript is generated: * *
{@code - * import { ServiceException as __BaseException } from "@aws-sdk/smithy-client"; * import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client"; + * import { ServiceException as __BaseException } from "@aws-sdk/smithy-client"; + * // In server SDK: + * // import { SmithyException as __BaseException } from "@aws-smithy/server-common"; * * export class NoSuchResource extends __BaseException { * name: "NoSuchResource"; diff --git a/smithy-typescript-ssdk-libs/server-common/src/errors.ts b/smithy-typescript-ssdk-libs/server-common/src/errors.ts index f0f6f4e35e8..2c320f38a4b 100644 --- a/smithy-typescript-ssdk-libs/server-common/src/errors.ts +++ b/smithy-typescript-ssdk-libs/server-common/src/errors.ts @@ -41,57 +41,52 @@ export const isFrameworkException = (error: any): error is SmithyFrameworkExcept return error.$frameworkError; }; -export class InternalFailureException extends SmithyException { +/** + * @internal + */ +export class InternalFailureException { readonly name = "InternalFailure"; readonly $fault = "server"; readonly statusCode = 500; readonly $frameworkError = true; - constructor() { - super({ name: "InternalFailure", $fault: "server" }); - Object.setPrototypeOf(this, InternalFailureException.prototype); - } } -export class UnknownOperationException extends SmithyException { +/** + * @internal + */ +export class UnknownOperationException { readonly name = "UnknownOperationException"; readonly $fault = "client"; readonly statusCode = 404; readonly $frameworkError = true; - constructor() { - super({ name: "UnknownOperationException", $fault: "client" }); - Object.setPrototypeOf(this, UnknownOperationException.prototype); - } } -export class SerializationException extends SmithyException { +/** + * @internal + */ +export class SerializationException { readonly name = "SerializationException"; readonly $fault = "client"; readonly statusCode = 400; readonly $frameworkError = true; - constructor() { - super({ name: "SerializationException", $fault: "client" }); - Object.setPrototypeOf(this, SerializationException.prototype); - } } -export class UnsupportedMediaTypeException extends SmithyException { +/** + * @internal + */ +export class UnsupportedMediaTypeException { readonly name = "UnsupportedMediaTypeException"; readonly $fault = "client"; readonly statusCode = 415; readonly $frameworkError = true; - constructor() { - super({ name: "UnsupportedMediaTypeException", $fault: "client" }); - Object.setPrototypeOf(this, UnsupportedMediaTypeException.prototype); - } } -export class NotAcceptableException extends SmithyException { +/** + * @internal + */ +export class NotAcceptableException { readonly name = "NotAcceptableException"; readonly $fault = "client"; readonly statusCode = 406; readonly $frameworkError = true; - constructor() { - super({ name: "NotAcceptableException", $fault: "client" }); - Object.setPrototypeOf(this, NotAcceptableException.prototype); - } }