Skip to content

Commit

Permalink
address feedback to not extend framework errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZhengYP committed Feb 16, 2022
1 parent 42d43bb commit c653965
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
Expand Up @@ -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.
*
* <p>Given the following Smithy structure:
*
Expand All @@ -192,8 +193,10 @@ private void renderStructureNamespace(StructuredMemberWriter structuredMemberWri
* <p>The following TypeScript is generated:
*
* <pre>{@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";
Expand Down
45 changes: 20 additions & 25 deletions smithy-typescript-ssdk-libs/server-common/src/errors.ts
Expand Up @@ -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);
}
}

0 comments on commit c653965

Please sign in to comment.