Skip to content

Commit c653965

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

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-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: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,57 +41,52 @@ export const isFrameworkException = (error: any): error is SmithyFrameworkExcept
4141
return error.$frameworkError;
4242
};
4343

44-
export class InternalFailureException extends SmithyException {
44+
/**
45+
* @internal
46+
*/
47+
export class InternalFailureException {
4548
readonly name = "InternalFailure";
4649
readonly $fault = "server";
4750
readonly statusCode = 500;
4851
readonly $frameworkError = true;
49-
constructor() {
50-
super({ name: "InternalFailure", $fault: "server" });
51-
Object.setPrototypeOf(this, InternalFailureException.prototype);
52-
}
5352
}
5453

55-
export class UnknownOperationException extends SmithyException {
54+
/**
55+
* @internal
56+
*/
57+
export class UnknownOperationException {
5658
readonly name = "UnknownOperationException";
5759
readonly $fault = "client";
5860
readonly statusCode = 404;
5961
readonly $frameworkError = true;
60-
constructor() {
61-
super({ name: "UnknownOperationException", $fault: "client" });
62-
Object.setPrototypeOf(this, UnknownOperationException.prototype);
63-
}
6462
}
6563

66-
export class SerializationException extends SmithyException {
64+
/**
65+
* @internal
66+
*/
67+
export class SerializationException {
6768
readonly name = "SerializationException";
6869
readonly $fault = "client";
6970
readonly statusCode = 400;
7071
readonly $frameworkError = true;
71-
constructor() {
72-
super({ name: "SerializationException", $fault: "client" });
73-
Object.setPrototypeOf(this, SerializationException.prototype);
74-
}
7572
}
7673

77-
export class UnsupportedMediaTypeException extends SmithyException {
74+
/**
75+
* @internal
76+
*/
77+
export class UnsupportedMediaTypeException {
7878
readonly name = "UnsupportedMediaTypeException";
7979
readonly $fault = "client";
8080
readonly statusCode = 415;
8181
readonly $frameworkError = true;
82-
constructor() {
83-
super({ name: "UnsupportedMediaTypeException", $fault: "client" });
84-
Object.setPrototypeOf(this, UnsupportedMediaTypeException.prototype);
85-
}
8682
}
8783

88-
export class NotAcceptableException extends SmithyException {
84+
/**
85+
* @internal
86+
*/
87+
export class NotAcceptableException {
8988
readonly name = "NotAcceptableException";
9089
readonly $fault = "client";
9190
readonly statusCode = 406;
9291
readonly $frameworkError = true;
93-
constructor() {
94-
super({ name: "NotAcceptableException", $fault: "client" });
95-
Object.setPrototypeOf(this, NotAcceptableException.prototype);
96-
}
9792
}

0 commit comments

Comments
 (0)