refactor(core): wrapInstance should return promise as-is

instance based method never throw errors like regular ones do
This commit is contained in:
Ibby Hadeed 2017-05-17 10:46:47 -04:00
parent 1ec4bdef8f
commit 8aca6718e1

View File

@ -297,16 +297,7 @@ export function wrapInstance(pluginObj: any, methodName: string, opts: any = {})
} else { } else {
let pluginResult: any, rej: Function; return getPromise((resolve: Function, reject: Function) => callInstance(pluginObj, methodName, args, opts, resolve, reject));
const p = getPromise((resolve: Function, reject: Function) => {
pluginResult = callInstance(pluginObj, methodName, args, opts, resolve, reject);
rej = reject;
});
if (pluginResult && pluginResult.error) {
p.catch(() => { });
typeof rej === 'function' && rej(pluginResult.error);
}
return p;
} }
}; };