Skip to content

Commit 64e9c61

Browse files
authored
chore(core/protocols): make error lookup in runtime protocol consistent with existing codegen (#7478)
1 parent b554e95 commit 64e9c61

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

packages/core/src/submodules/protocols/ProtocolLib.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrorSchema, NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
1+
import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
22
import type { HttpResponse as IHttpResponse, MetadataBearer, ResponseMetadata, StaticErrorSchema } from "@smithy/types";
33

44
/**

packages/core/src/submodules/protocols/query/AwsQueryProtocol.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,15 @@ export class AwsQueryProtocol extends RpcProtocol {
158158
response,
159159
errorData,
160160
metadata,
161-
(registry: TypeRegistry, errorName: string) =>
162-
registry.find(
163-
(schema) => (NormalizedSchema.of(schema).getMergedTraits().awsQueryError as any)?.[0] === errorName
164-
) as StaticErrorSchema
161+
(registry: TypeRegistry, errorName: string) => {
162+
try {
163+
return registry.getSchema(errorName) as StaticErrorSchema;
164+
} catch (e) {
165+
return registry.find(
166+
(schema) => (NormalizedSchema.of(schema).getMergedTraits().awsQueryError as any)?.[0] === errorName
167+
) as StaticErrorSchema;
168+
}
169+
}
165170
);
166171

167172
const ns = NormalizedSchema.of(errorSchema);

0 commit comments

Comments
 (0)