From f3fb8b490b0146d245fdada60f940b5d4f9a4b43 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 1 Feb 2023 07:26:56 -0500 Subject: [PATCH] *Add handleErrorOrReturn helper method --- src/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index ed4aef3..3d42f2f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -50,9 +50,7 @@ export abstract class Client { const moduleBag = await this.loadBound(module); this._callModule = async (...args) => { const ret = await moduleBag.callModule(...args); - this.handleError(ret); - - return ret; + return this.handleErrorOrReturn(ret); }; this._connectModule = moduleBag.connectModule; } @@ -66,6 +64,10 @@ export abstract class Client { throw new Error(ret[1]); } } + protected handleErrorOrReturn(ret: ErrTuple): any { + this.handleError(ret); + return ret[0]; + } protected async callModuleReturn(method: string, data?: any): Promise { const ret = await this.callModule(method, data);