*Add handleErrorOrReturn helper method

This commit is contained in:
Derrick Hammer 2023-02-01 07:26:56 -05:00
parent fb377db59f
commit f3fb8b490b
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 5 additions and 3 deletions

View File

@ -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<any> {
const ret = await this.callModule(method, data);