@@ -13,7 +13,7 @@ export class TypeRegistry {
1313 private constructor (
1414 public readonly namespace : string ,
1515 private schemas : Map < string , ISchema > = new Map ( ) ,
16- private exceptions : Map < ErrorSchema | StaticErrorSchema , any > = new Map ( )
16+ private exceptions : Map < StaticErrorSchema , any > = new Map ( )
1717 ) { }
1818
1919 /**
@@ -53,16 +53,17 @@ export class TypeRegistry {
5353 /**
5454 * Associates an error schema with its constructor.
5555 */
56- public registerError ( es : ErrorSchema | StaticErrorSchema , ctor : any ) {
56+ public registerError ( es : StaticErrorSchema , ctor : any ) {
5757 this . exceptions . set ( es , ctor ) ;
58+ this . register ( es [ 1 ] + "#" + es [ 2 ] , es ) ;
5859 }
5960
6061 /**
6162 * @param es - query.
6263 * @returns Error constructor that extends the service's base exception.
6364 */
6465 public getErrorCtor ( es : ErrorSchema | StaticErrorSchema ) : any {
65- return this . exceptions . get ( es ) ;
66+ return this . exceptions . get ( es as StaticErrorSchema ) ;
6667 }
6768
6869 /**
@@ -78,10 +79,14 @@ export class TypeRegistry {
7879 *
7980 * @returns the synthetic base exception of the service namespace associated with this registry instance.
8081 */
81- public getBaseException ( ) : ErrorSchema | undefined {
82- for ( const [ id , schema ] of this . schemas . entries ( ) ) {
83- if ( id . startsWith ( "smithy.ts.sdk.synthetic." ) && id . endsWith ( "ServiceException" ) ) {
84- return schema as ErrorSchema ;
82+ public getBaseException ( ) : StaticErrorSchema | undefined {
83+ for ( const exceptionKey of this . exceptions . keys ( ) ) {
84+ if ( Array . isArray ( exceptionKey ) ) {
85+ const [ , ns , name ] = exceptionKey ;
86+ const id = ns + "#" + name ;
87+ if ( id . startsWith ( "smithy.ts.sdk.synthetic." ) && id . endsWith ( "ServiceException" ) ) {
88+ return exceptionKey ;
89+ }
8590 }
8691 }
8792 return undefined ;
0 commit comments