@@ -220,11 +220,21 @@ function _normalize(value: any): string {
220220 throw new Error ( "Hmm..." ) ;
221221}
222222
223- function normalizeResult ( value : RunnerResult ) : { tag : string , value : any } {
223+ function normalizeResult ( method : string , value : RunnerResult ) : { tag : string , value : any } {
224224
225225 if ( "error" in value ) {
226226 const error = value . error ;
227- return { tag : _normalize ( error ) , value : error } ;
227+
228+ let tag : string ;
229+ if ( isError ( error , "CALL_EXCEPTION" ) ) {
230+ tag = _normalize ( Object . assign ( { } , error , {
231+ shortMessage : undefined , reason : undefined , info : undefined
232+ } ) ) ;
233+ } else {
234+ tag = _normalize ( error )
235+ }
236+
237+ return { tag, value : error } ;
228238 }
229239
230240 const result = value . result ;
@@ -248,7 +258,6 @@ function checkQuorum(quorum: number, results: Array<TallyResult>): any | Error {
248258 }
249259
250260 let best : null | { value : any , weight : number } = null ;
251-
252261 for ( const r of tally . values ( ) ) {
253262 if ( r . weight >= quorum && ( ! best || r . weight > best . weight ) ) {
254263 best = r ;
@@ -586,7 +595,7 @@ export class FallbackProvider extends AbstractProvider {
586595 const results : Array < TallyResult > = [ ] ;
587596 for ( const runner of running ) {
588597 if ( runner . result != null ) {
589- const { tag, value } = normalizeResult ( runner . result ) ;
598+ const { tag, value } = normalizeResult ( req . method , runner . result ) ;
590599 results . push ( { tag, value, weight : runner . config . weight } ) ;
591600 }
592601 }
@@ -716,9 +725,9 @@ export class FallbackProvider extends AbstractProvider {
716725 const broadcasts = this . #configs. map ( async ( { provider, weight } , index ) => {
717726 try {
718727 const result = await provider . _perform ( req ) ;
719- results [ index ] = Object . assign ( normalizeResult ( { result } ) , { weight } ) ;
728+ results [ index ] = Object . assign ( normalizeResult ( req . method , { result } ) , { weight } ) ;
720729 } catch ( error : any ) {
721- results [ index ] = Object . assign ( normalizeResult ( { error } ) , { weight } ) ;
730+ results [ index ] = Object . assign ( normalizeResult ( req . method , { error } ) , { weight } ) ;
722731 }
723732 } ) ;
724733
0 commit comments