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);