Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funny-pigs-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smithy/core": patch
---

use smithy synthetic namespace for base errors
17 changes: 10 additions & 7 deletions packages/core/src/submodules/schema/TypeRegistry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ import { struct } from "./schemas/StructureSchema";
import { TypeRegistry } from "./TypeRegistry";

describe(TypeRegistry.name, () => {
const [List, Map, Struct] = [list("ack", "List", { sparse: 1 }, 0), map("ack", "Map", 0, 0, 1), () => schema];
const schema = struct("ack", "Structure", {}, ["list", "map", "struct"], [List, Map, Struct]);

const tr = TypeRegistry.for("ack");
const [List, Map, Struct] = [
list("NAMESPACE", "List", { sparse: 1 }, 0),
map("NAMESPACE", "Map", 0, 0, 1),
() => schema,
];
const schema = struct("NAMESPACE", "Structure", {}, ["list", "map", "struct"], [List, Map, Struct]);

it("stores and retrieves schema objects", () => {
const tr = TypeRegistry.for("NAMESPACE");
expect(tr.getSchema("List")).toBe(List);
expect(tr.getSchema("Map")).toBe(Map);
expect(tr.getSchema("Structure")).toBe(schema);
});

it("has a helper method to retrieve a synthetic base exception", () => {
// the service namespace is appended to the synthetic prefix.
const err = error("smithyts.client.synthetic.ack", "UhOhServiceException", 0, [], [], Error);
const tr = TypeRegistry.for("smithyts.client.synthetic.ack");
expect(tr.getBaseException()).toEqual(err);
const err = error("smithy.ts.sdk.synthetic.NAMESPACE", "UhOhServiceException", 0, [], [], Error);
const tr = TypeRegistry.for("smithy.ts.sdk.synthetic.NAMESPACE");
expect(tr.getBaseException()).toBe(err);
});
});
2 changes: 1 addition & 1 deletion packages/core/src/submodules/schema/TypeRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class TypeRegistry {
*/
public getBaseException(): ErrorSchema | undefined {
for (const [id, schema] of this.schemas.entries()) {
if (id.startsWith("smithyts.client.synthetic.") && id.endsWith("ServiceException")) {
if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
return schema as ErrorSchema;
}
}
Expand Down