*Add handleErrorOrReturn helper method
This commit is contained in:
parent
fb377db59f
commit
f3fb8b490b
|
@ -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);
|
||||
|
||||
|
|
Reference in New Issue