Skip to content

Commit d2a1497

Browse files
committed
rename SmithyException in ssdk to ServiceException
1 parent ca7741d commit d2a1497

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,9 @@ 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-smithy/server-common");
744+
writer.addImport("ServiceException", "__ServiceException", "@aws-smithy/server-common");
745745
writer.addImport("OperationSerializer", "__OperationSerializer", "@aws-smithy/server-common");
746-
writer.openBlock("const serFn: (op: $1T) => __OperationSerializer<$2T<{}>, $1T, __SmithyException> = (op) =>"
746+
writer.openBlock("const serFn: (op: $1T) => __OperationSerializer<$2T<{}>, $1T, __ServiceException> = (op) =>"
747747
+ " { return new TestSerializer(); };", serviceOperationsSymbol, serviceSymbol);
748748

749749
writer.addImport("serializeFrameworkException", null,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static void generateServiceHandler(SymbolProvider symbolProvider,
6363
writer.write("private readonly service: $T<Context>;", serviceSymbol);
6464
writer.write("private readonly mux: __Mux<$S, $T>;", serviceShape.getId().getName(), operationsType);
6565
writer.write("private readonly serializerFactory: <T extends $T>(operation: T) => "
66-
+ "__OperationSerializer<$T<Context>, T, __SmithyException>;",
66+
+ "__OperationSerializer<$T<Context>, T, __ServiceException>;",
6767
operationsType, serviceSymbol);
6868
writer.write("private readonly serializeFrameworkException: (e: __SmithyFrameworkException, "
6969
+ "ctx: __ServerSerdeContext) => Promise<__HttpResponse>;");
@@ -87,7 +87,7 @@ static void generateServiceHandler(SymbolProvider symbolProvider,
8787
writer.write("service: $T<Context>,", serviceSymbol);
8888
writer.write("mux: __Mux<$S, $T>,", serviceShape.getId().getName(), operationsType);
8989
writer.write("serializerFactory:<T extends $T>(op: T) => "
90-
+ "__OperationSerializer<$T<Context>, T, __SmithyException>,",
90+
+ "__OperationSerializer<$T<Context>, T, __ServiceException>,",
9191
operationsType, serviceSymbol);
9292
writer.write("serializeFrameworkException: (e: __SmithyFrameworkException, ctx: __ServerSerdeContext) "
9393
+ "=> Promise<__HttpResponse>,");
@@ -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-smithy/server-common");
211+
writer.addImport("ServiceException", "__ServiceException", "@aws-smithy/server-common");
212212
writer.addImport("ValidationCustomizer", "__ValidationCustomizer", "@aws-smithy/server-common");
213213
}
214214

@@ -226,7 +226,7 @@ private static void writeHandleFunction(TypeScriptWriter writer) {
226226
writer.write("request: __HttpRequest,");
227227
writer.write("context: Context,");
228228
writer.write("operationName: O,");
229-
writer.write("serializer: __OperationSerializer<S, O, __SmithyException>,");
229+
writer.write("serializer: __OperationSerializer<S, O, __ServiceException>,");
230230
writer.write("operation: __Operation<__OperationInput<S[O]>, __OperationOutput<S[O]>, Context>,");
231231
writer.write("serializeFrameworkException: (e: __SmithyFrameworkException, "
232232
+ "ctx: __ServerSerdeContext) => Promise<__HttpResponse>,");

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private void renderStructureNamespace(StructuredMemberWriter structuredMemberWri
175175

176176
/**
177177
* Error structures generate classes that extend from ServiceException
178-
* (SmithyException is case of server SDK), and add the appropriate fault
178+
* (ServiceException is case of server SDK), and add the appropriate fault
179179
* property.
180180
*
181181
* <p>Given the following Smithy structure:
@@ -196,7 +196,7 @@ private void renderStructureNamespace(StructuredMemberWriter structuredMemberWri
196196
* import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client";
197197
* import { ServiceException as __BaseException } from "@aws-sdk/smithy-client";
198198
* // In server SDK:
199-
* // import { SmithyException as __BaseException } from "@aws-smithy/server-common";
199+
* // import { ServiceException as __BaseException } from "@aws-smithy/server-common";
200200
*
201201
* export class NoSuchResource extends __BaseException {
202202
* name: "NoSuchResource";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ 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-
writer.addImport("SmithyException", "__BaseException", TypeScriptDependency.SERVER_COMMON.packageName);
133+
writer.addImport("ServiceException", "__BaseException", TypeScriptDependency.SERVER_COMMON.packageName);
134134
} else {
135135
writer.addImport("ServiceException", "__BaseException", TypeScriptDependency.AWS_SMITHY_CLIENT.packageName);
136136
writer.writeDocs("@internal");

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
package software.amazon.smithy.typescript.codegen.integration;
1717

18-
import software.amazon.smithy.codegen.core.Symbol;
1918
import software.amazon.smithy.codegen.core.SymbolProvider;
2019
import software.amazon.smithy.model.Model;
2120
import software.amazon.smithy.model.shapes.ServiceShape;
@@ -40,8 +39,9 @@ public void writeAdditionalExports(
4039
boolean isClientSdk = settings.generateClient();
4140
if (isClientSdk) {
4241
ServiceShape service = settings.getService(model);
43-
Symbol symbol = symbolProvider.toSymbol(service);
44-
writer.write("export { ServiceException as $LServiceException } from $S;", symbol.getName(),
42+
String clientName = symbolProvider.toSymbol(service).getName();
43+
String serviceName = clientName.replaceAll("(Client)$", "");
44+
writer.write("export { ServiceException as $LServiceException } from $S;", serviceName,
4545
TypeScriptDependency.AWS_SMITHY_CLIENT.packageName);
4646
}
4747
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ public void generateServiceHandlerFactory(GenerationContext context) {
363363
writer.indent();
364364

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

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

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

16-
export class SmithyException extends Error {
16+
export class ServiceException extends Error {
1717
/**
1818
* Whether the client or server are at fault.
1919
*/
2020
readonly $fault: "client" | "server";
2121

2222
constructor(options: { name: string; $fault: "client" | "server"; message?: string }) {
2323
super(options.message);
24-
Object.setPrototypeOf(this, SmithyException.prototype);
24+
Object.setPrototypeOf(this, ServiceException.prototype);
2525
this.name = options.name;
2626
this.$fault = options.$fault;
2727
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ export * from "./validation";
2121
import { HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
2222
import { SerdeContext } from "@aws-sdk/types";
2323

24-
import { SmithyException } from "./errors";
24+
import { ServiceException } from "./errors";
2525

2626
export type Operation<I, O, Context = {}> = (input: I, context: Context) => Promise<O>;
2727

2828
export type OperationInput<T> = T extends Operation<infer I, any, any> ? I : never;
2929
export type OperationOutput<T> = T extends Operation<any, infer O, any> ? O : never;
3030

31-
export interface OperationSerializer<T, K extends keyof T, E extends SmithyException> {
31+
export interface OperationSerializer<T, K extends keyof T, E extends ServiceException> {
3232
serialize(input: OperationOutput<T[K]>, ctx: ServerSerdeContext): Promise<HttpResponse>;
3333
deserialize(input: HttpRequest, ctx: SerdeContext): Promise<OperationInput<T[K]>>;
3434
isOperationError(error: any): error is E;

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

Lines changed: 2 additions & 2 deletions
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 "../errors";
16+
import { ServiceException } from "../errors";
1717

1818
export * from "./validators";
1919

@@ -76,7 +76,7 @@ export interface ValidationContext<O extends string> {
7676
export type ValidationCustomizer<O extends string> = (
7777
context: ValidationContext<O>,
7878
failures: ValidationFailure[]
79-
) => SmithyException | undefined;
79+
) => ServiceException | undefined;
8080

8181
export const generateValidationSummary = (failures: readonly ValidationFailure[]): string => {
8282
const failingPaths = new Set(failures.map((failure) => failure.path));

0 commit comments

Comments
 (0)