Skip to content

Commit 147ceed

Browse files
authored
chore: use smithy synthetic namespace for service base exceptions (#1613)
1 parent 0dae5d8 commit 147ceed

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

.changeset/funny-pigs-kiss.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/core": patch
3+
---
4+
5+
use smithy synthetic namespace for base errors

packages/core/src/submodules/schema/TypeRegistry.spec.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@ import { struct } from "./schemas/StructureSchema";
77
import { TypeRegistry } from "./TypeRegistry";
88

99
describe(TypeRegistry.name, () => {
10-
const [List, Map, Struct] = [list("ack", "List", { sparse: 1 }, 0), map("ack", "Map", 0, 0, 1), () => schema];
11-
const schema = struct("ack", "Structure", {}, ["list", "map", "struct"], [List, Map, Struct]);
12-
13-
const tr = TypeRegistry.for("ack");
10+
const [List, Map, Struct] = [
11+
list("NAMESPACE", "List", { sparse: 1 }, 0),
12+
map("NAMESPACE", "Map", 0, 0, 1),
13+
() => schema,
14+
];
15+
const schema = struct("NAMESPACE", "Structure", {}, ["list", "map", "struct"], [List, Map, Struct]);
1416

1517
it("stores and retrieves schema objects", () => {
18+
const tr = TypeRegistry.for("NAMESPACE");
1619
expect(tr.getSchema("List")).toBe(List);
1720
expect(tr.getSchema("Map")).toBe(Map);
1821
expect(tr.getSchema("Structure")).toBe(schema);
1922
});
2023

2124
it("has a helper method to retrieve a synthetic base exception", () => {
2225
// the service namespace is appended to the synthetic prefix.
23-
const err = error("smithyts.client.synthetic.ack", "UhOhServiceException", 0, [], [], Error);
24-
const tr = TypeRegistry.for("smithyts.client.synthetic.ack");
25-
expect(tr.getBaseException()).toEqual(err);
26+
const err = error("smithy.ts.sdk.synthetic.NAMESPACE", "UhOhServiceException", 0, [], [], Error);
27+
const tr = TypeRegistry.for("smithy.ts.sdk.synthetic.NAMESPACE");
28+
expect(tr.getBaseException()).toBe(err);
2629
});
2730
});

packages/core/src/submodules/schema/TypeRegistry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class TypeRegistry {
6565
*/
6666
public getBaseException(): ErrorSchema | undefined {
6767
for (const [id, schema] of this.schemas.entries()) {
68-
if (id.startsWith("smithyts.client.synthetic.") && id.endsWith("ServiceException")) {
68+
if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
6969
return schema as ErrorSchema;
7070
}
7171
}

0 commit comments

Comments
 (0)