difftreelog
feat catch dispatchError in playgrounds
in: master
2 files changed
tests/src/util/playgrounds/types.tsdiffbeforeafterboth14export interface ITransactionResult {14export interface ITransactionResult {15 status: 'Fail' | 'Success';15 status: 'Fail' | 'Success';16 result: {16 result: {17 dispatchError: any,17 events: {18 events: {18 phase: any, // {ApplyExtrinsic: number} | 'Initialization',19 phase: any, // {ApplyExtrinsic: number} | 'Initialization',19 event: IEvent;20 event: IEvent;47 call: string;48 call: string;48 params: any[];49 params: any[];49 moduleError?: string;50 moduleError?: string;51 dispatchError?: any;50 events?: any;52 events?: any;51}53}5254tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- 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;
}