From 4a02655589a8bf25d0b39d2b9c09b72ced729164 Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Thu, 06 Oct 2022 14:09:58 +0000 Subject: [PATCH] feat: catch dispatchError in playgrounds --- --- a/tests/src/util/playgrounds/types.ts +++ b/tests/src/util/playgrounds/types.ts @@ -14,6 +14,7 @@ export interface ITransactionResult { status: 'Fail' | 'Success'; result: { + dispatchError: any, events: { phase: any, // {ApplyExtrinsic: number} | 'Initialization', event: IEvent; @@ -47,6 +48,7 @@ call: string; params: any[]; moduleError?: string; + dispatchError?: any; events?: any; } --- a/tests/src/util/playgrounds/unique.ts +++ b/tests/src/util/playgrounds/unique.ts @@ -514,12 +514,18 @@ params, } as IUniqueHelperLog; - if(result.status !== this.transactionStatus.SUCCESS && result.moduleError) log.moduleError = result.moduleError; + if(result.status !== this.transactionStatus.SUCCESS) { + if (result.moduleError) log.moduleError = result.moduleError; + else if (result.result.dispatchError) log.dispatchError = result.result.dispatchError; + } if(events.length > 0) log.events = events; this.chainLog.push(log); - if(expectSuccess && result.status !== this.transactionStatus.SUCCESS) throw Error(`${result.moduleError}`); + if(expectSuccess && result.status !== this.transactionStatus.SUCCESS) { + if (result.moduleError) throw Error(`${result.moduleError}`); + else if (result.result.dispatchError) throw Error(JSON.stringify(result.result.dispatchError)); + } return result; } -- gitstuff