diff --git a/packages/core/src/submodules/protocols/ProtocolLib.ts b/packages/core/src/submodules/protocols/ProtocolLib.ts index bfe84937d764..69efd0298805 100644 --- a/packages/core/src/submodules/protocols/ProtocolLib.ts +++ b/packages/core/src/submodules/protocols/ProtocolLib.ts @@ -1,4 +1,4 @@ -import { ErrorSchema, NormalizedSchema, TypeRegistry } from "@smithy/core/schema"; +import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema"; import type { HttpResponse as IHttpResponse, MetadataBearer, ResponseMetadata, StaticErrorSchema } from "@smithy/types"; /** diff --git a/packages/core/src/submodules/protocols/query/AwsQueryProtocol.ts b/packages/core/src/submodules/protocols/query/AwsQueryProtocol.ts index 8a74530c19bc..6f55e614b567 100644 --- a/packages/core/src/submodules/protocols/query/AwsQueryProtocol.ts +++ b/packages/core/src/submodules/protocols/query/AwsQueryProtocol.ts @@ -158,10 +158,15 @@ export class AwsQueryProtocol extends RpcProtocol { response, errorData, metadata, - (registry: TypeRegistry, errorName: string) => - registry.find( - (schema) => (NormalizedSchema.of(schema).getMergedTraits().awsQueryError as any)?.[0] === errorName - ) as StaticErrorSchema + (registry: TypeRegistry, errorName: string) => { + try { + return registry.getSchema(errorName) as StaticErrorSchema; + } catch (e) { + return registry.find( + (schema) => (NormalizedSchema.of(schema).getMergedTraits().awsQueryError as any)?.[0] === errorName + ) as StaticErrorSchema; + } + } ); const ns = NormalizedSchema.of(errorSchema);