Skip to content

Commit 5586a0f

Browse files
committed
rename ClientException to SmithyClient in server-common package
1 parent b6eba7c commit 5586a0f

File tree

9 files changed

+49
-32
lines changed

9 files changed

+49
-32
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ private void writeServerResponseTest(OperationShape operation, HttpResponseTestC
741741
writer.write("const request = new HttpRequest({method: 'POST', hostname: 'example.com'});");
742742

743743
// Create a new serializer factory that always returns our test serializer.
744-
writer.addImport("SmithyException", "__SmithyException", "@aws-sdk/types");
744+
writer.addImport("SmithyException", "__SmithyException", "@aws-smithy/server-common");
745745
writer.addImport("OperationSerializer", "__OperationSerializer", "@aws-smithy/server-common");
746746
writer.openBlock("const serFn: (op: $1T) => __OperationSerializer<$2T<{}>, $1T, __SmithyException> = (op) =>"
747747
+ " { return new TestSerializer(); };", serviceOperationsSymbol, serviceSymbol);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private static void addCommonHandlerImports(TypeScriptWriter writer) {
208208
writer.addImport("SmithyFrameworkException", "__SmithyFrameworkException", "@aws-smithy/server-common");
209209
writer.addImport("HttpRequest", "__HttpRequest", "@aws-sdk/protocol-http");
210210
writer.addImport("HttpResponse", "__HttpResponse", "@aws-sdk/protocol-http");
211-
writer.addImport("SmithyException", "__SmithyException", "@aws-sdk/types");
211+
writer.addImport("SmithyException", "__SmithyException", "@aws-smithy/server-common");
212212
writer.addImport("ValidationCustomizer", "__ValidationCustomizer", "@aws-smithy/server-common");
213213
}
214214

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ void writeErrorConstructor(TypeScriptWriter writer, Shape shape, boolean isServe
130130
ErrorTrait errorTrait = shape.getTrait(ErrorTrait.class).orElseThrow(IllegalStateException::new);
131131
Symbol symbol = symbolProvider.toSymbol(shape);
132132
if (isServerSdk) {
133-
// TODO: change to import from @aws-smithy/server-common
134-
writer.addImport("ClientException", "__BaseException", "@aws-sdk/smithy-client");
133+
writer.addImport("SmithyException", "__BaseException", TypeScriptDependency.SERVER_COMMON.packageName);
135134
} else {
136-
writer.addImport("ServiceException", "__BaseException", "@aws-sdk/smithy-client");
135+
writer.addImport("ServiceException", "__BaseException", TypeScriptDependency.AWS_SMITHY_CLIENT.packageName);
137136
writer.writeDocs("@internal");
138137
}
139-
writer.addImport("ExceptionOptionType", "__ExceptionOptionType", "@aws-sdk/smithy-client");
138+
writer.addImport("ExceptionOptionType", "__ExceptionOptionType",
139+
TypeScriptDependency.AWS_SMITHY_CLIENT.packageName);
140140
writer.openBlock("constructor(opts: __ExceptionOptionType<$L, __BaseException>) {", symbol.getName());
141141
writer.openBlock("super({", "});", () -> {
142142
writer.write("name: $S,", shape.getId().getName());

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ public void generateServiceHandlerFactory(GenerationContext context) {
363363
writer.indent();
364364

365365
generateServiceMux(context);
366-
writer.addImport("SmithyException", "__SmithyException", "@aws-sdk/types");
366+
writer.addImport("SmithyException", "__SmithyException", "@aws-smithy/server-common");
367367
writer.openBlock("const serFn: (op: $1T) => __OperationSerializer<$2T<Context>, $1T, __SmithyException> = "
368368
+ "(op) => {", "};", operationsSymbol, serviceSymbol, () -> {
369369
writer.openBlock("switch (op) {", "}", () -> {

smithy-typescript-ssdk-libs/server-common/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"license": "Apache-2.0",
2121
"dependencies": {
2222
"@aws-sdk/protocol-http": "3.40.0",
23-
"@aws-sdk/smithy-client": "3.41.0",
2423
"@aws-sdk/types": "3.40.0",
2524
"tslib": "^1.8.0",
2625
"re2-wasm": "^1.0.2"

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

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,20 @@
1313
* permissions and limitations under the License.
1414
*/
1515

16-
import { SmithyException } from "@aws-sdk/smithy-client";
16+
export class SmithyException extends Error {
17+
/**
18+
* Whether the client or server are at fault.
19+
*/
20+
readonly $fault: "client" | "server";
21+
22+
constructor(options: { name: string; $fault: "client" | "server"; message?: string }) {
23+
super(options.message);
24+
Object.setPrototypeOf(this, SmithyException.prototype);
25+
this.name = options.name;
26+
this.$fault = options.$fault;
27+
}
28+
}
29+
1730

1831
export type SmithyFrameworkException =
1932
| InternalFailureException
@@ -29,37 +42,57 @@ export const isFrameworkException = (error: any): error is SmithyFrameworkExcept
2942
return error.$frameworkError;
3043
};
3144

32-
export class InternalFailureException implements SmithyException {
45+
export class InternalFailureException extends SmithyException {
3346
readonly name = "InternalFailure";
3447
readonly $fault = "server";
3548
readonly statusCode = 500;
3649
readonly $frameworkError = true;
50+
constructor() {
51+
super({name: "InternalFailure", $fault: "server"});
52+
Object.setPrototypeOf(this, InternalFailureException.prototype);
53+
}
3754
}
3855

39-
export class UnknownOperationException implements SmithyException {
56+
export class UnknownOperationException extends SmithyException {
4057
readonly name = "UnknownOperationException";
4158
readonly $fault = "client";
4259
readonly statusCode = 404;
4360
readonly $frameworkError = true;
61+
constructor() {
62+
super({name: "UnknownOperationException", $fault: "client"});
63+
Object.setPrototypeOf(this, UnknownOperationException.prototype);
64+
}
4465
}
4566

46-
export class SerializationException implements SmithyException {
67+
export class SerializationException extends SmithyException {
4768
readonly name = "SerializationException";
4869
readonly $fault = "client";
4970
readonly statusCode = 400;
5071
readonly $frameworkError = true;
72+
constructor() {
73+
super({name: "SerializationException", $fault: "client"});
74+
Object.setPrototypeOf(this, SerializationException.prototype);
75+
}
5176
}
5277

53-
export class UnsupportedMediaTypeException implements SmithyException {
78+
export class UnsupportedMediaTypeException extends SmithyException {
5479
readonly name = "UnsupportedMediaTypeException";
5580
readonly $fault = "client";
5681
readonly statusCode = 415;
5782
readonly $frameworkError = true;
83+
constructor() {
84+
super({name: "UnsupportedMediaTypeException", $fault: "client"});
85+
Object.setPrototypeOf(this, UnsupportedMediaTypeException.prototype);
86+
}
5887
}
5988

60-
export class NotAcceptableException implements SmithyException {
89+
export class NotAcceptableException extends SmithyException {
6190
readonly name = "NotAcceptableException";
6291
readonly $fault = "client";
6392
readonly statusCode = 406;
6493
readonly $frameworkError = true;
94+
constructor() {
95+
super({name: "NotAcceptableException", $fault: "client"});
96+
Object.setPrototypeOf(this, NotAcceptableException.prototype);
97+
}
6598
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ export * from "./errors";
1919
export * from "./validation";
2020

2121
import { HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
22-
import { SmithyException } from "@aws-sdk/smithy-client";
2322
import { SerdeContext } from "@aws-sdk/types";
2423

24+
import { SmithyException } from "./errors";
25+
2526
export type Operation<I, O, Context = {}> = (input: I, context: Context) => Promise<O>;
2627

2728
export type OperationInput<T> = T extends Operation<infer I, any, any> ? I : never;

smithy-typescript-ssdk-libs/server-common/src/validation/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* permissions and limitations under the License.
1414
*/
1515

16-
import { SmithyException } from "@aws-sdk/smithy-client";
16+
import { SmithyException } from "../errors";
1717

1818
export * from "./validators";
1919

smithy-typescript-ssdk-libs/yarn.lock

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22
# yarn lockfile v1
33

44

5-
"@aws-sdk/[email protected]":
6-
version "3.40.0"
7-
resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-stack/-/middleware-stack-3.40.0.tgz#5aa614e49a4fc76cc63986fb45302f7afab6db87"
8-
integrity sha512-hby9HvESUYJxpdALX+6Dn2LPmS5jtMVurGB/+j3MWOvIcDYB4bcSXgVRvXzYnTKwbSupIdbX9zOE2ZAx2SJpUQ==
9-
dependencies:
10-
tslib "^2.3.0"
11-
125
"@aws-sdk/[email protected]":
136
version "3.40.0"
147
resolved "https://registry.yarnpkg.com/@aws-sdk/protocol-http/-/protocol-http-3.40.0.tgz#ce6c7170a59e0a0eb63df5cd7cec87fe05bae680"
@@ -17,15 +10,6 @@
1710
"@aws-sdk/types" "3.40.0"
1811
tslib "^2.3.0"
1912

20-
"@aws-sdk/[email protected]":
21-
version "3.41.0"
22-
resolved "https://registry.yarnpkg.com/@aws-sdk/smithy-client/-/smithy-client-3.41.0.tgz#61154b4813a01dc079e7083805a20e1bc05d3199"
23-
integrity sha512-ldhS0Pf3v6yHCd//kk5DvKcdyeUkKEwxNDRanAp+ekTW68J3XcYgKaPC9sNDhVTDH1zrywTvtEz5zWHEvXjQow==
24-
dependencies:
25-
"@aws-sdk/middleware-stack" "3.40.0"
26-
"@aws-sdk/types" "3.40.0"
27-
tslib "^2.3.0"
28-
2913
"@aws-sdk/[email protected]":
3014
version "3.40.0"
3115
resolved "https://registry.yarnpkg.com/@aws-sdk/types/-/types-3.40.0.tgz#a9d7926fcb9b699bc46be975033559d2293e60d1"

0 commit comments

Comments
 (0)