Skip to content

Commit 786c91a

Browse files
committed
address feedback to not extend framework errors
1 parent 42d43bb commit 786c91a

File tree

2 files changed

+11
-28
lines changed

2 files changed

+11
-28
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructureGenerator.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ private void renderStructureNamespace(StructuredMemberWriter structuredMemberWri
174174
}
175175

176176
/**
177-
* Error structures generate interfaces that extend from SmithyException
178-
* and add the appropriate fault property.
177+
* Error structures generate classes that extend from ServiceException
178+
* (SmithyException is case of server SDK), and add the appropriate fault
179+
* property.
179180
*
180181
* <p>Given the following Smithy structure:
181182
*
@@ -192,8 +193,10 @@ private void renderStructureNamespace(StructuredMemberWriter structuredMemberWri
192193
* <p>The following TypeScript is generated:
193194
*
194195
* <pre>{@code
195-
* import { ServiceException as __BaseException } from "@aws-sdk/smithy-client";
196196
* import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client";
197+
* import { ServiceException as __BaseException } from "@aws-sdk/smithy-client";
198+
* // In server SDK:
199+
* // import { SmithyException as __BaseException } from "@aws-smithy/server-common";
197200
*
198201
* export class NoSuchResource extends __BaseException {
199202
* name: "NoSuchResource";

smithy-typescript-ssdk-libs/server-common/src/errors.ts

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,57 +41,37 @@ export const isFrameworkException = (error: any): error is SmithyFrameworkExcept
4141
return error.$frameworkError;
4242
};
4343

44-
export class InternalFailureException extends SmithyException {
44+
export class InternalFailureException {
4545
readonly name = "InternalFailure";
4646
readonly $fault = "server";
4747
readonly statusCode = 500;
4848
readonly $frameworkError = true;
49-
constructor() {
50-
super({ name: "InternalFailure", $fault: "server" });
51-
Object.setPrototypeOf(this, InternalFailureException.prototype);
52-
}
5349
}
5450

55-
export class UnknownOperationException extends SmithyException {
51+
export class UnknownOperationException {
5652
readonly name = "UnknownOperationException";
5753
readonly $fault = "client";
5854
readonly statusCode = 404;
5955
readonly $frameworkError = true;
60-
constructor() {
61-
super({ name: "UnknownOperationException", $fault: "client" });
62-
Object.setPrototypeOf(this, UnknownOperationException.prototype);
63-
}
6456
}
6557

66-
export class SerializationException extends SmithyException {
58+
export class SerializationException {
6759
readonly name = "SerializationException";
6860
readonly $fault = "client";
6961
readonly statusCode = 400;
7062
readonly $frameworkError = true;
71-
constructor() {
72-
super({ name: "SerializationException", $fault: "client" });
73-
Object.setPrototypeOf(this, SerializationException.prototype);
74-
}
7563
}
7664

77-
export class UnsupportedMediaTypeException extends SmithyException {
65+
export class UnsupportedMediaTypeException {
7866
readonly name = "UnsupportedMediaTypeException";
7967
readonly $fault = "client";
8068
readonly statusCode = 415;
8169
readonly $frameworkError = true;
82-
constructor() {
83-
super({ name: "UnsupportedMediaTypeException", $fault: "client" });
84-
Object.setPrototypeOf(this, UnsupportedMediaTypeException.prototype);
85-
}
8670
}
8771

88-
export class NotAcceptableException extends SmithyException {
72+
export class NotAcceptableException {
8973
readonly name = "NotAcceptableException";
9074
readonly $fault = "client";
9175
readonly statusCode = 406;
9276
readonly $frameworkError = true;
93-
constructor() {
94-
super({ name: "NotAcceptableException", $fault: "client" });
95-
Object.setPrototypeOf(this, NotAcceptableException.prototype);
96-
}
9777
}

0 commit comments

Comments
 (0)