Skip to content

Commit

Permalink
fix(core): handle unexpected errors in wrapOtherPromise
Browse files Browse the repository at this point in the history
fixes #1185
  • Loading branch information
ihadeed committed Mar 27, 2017
1 parent fd0a2e9 commit 9074362
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/@ionic-native/core/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,16 @@ function wrapPromise(pluginObj: any, methodName: string, args: any[], opts: any

function wrapOtherPromise(pluginObj: any, methodName: string, args: any[], opts: any= {}) {
return getPromise((resolve, reject) => {
let pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts);
if (pluginResult && pluginResult.error) {
reject(pluginResult.error);
const pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts);
if (pluginResult) {
if (pluginResult.error) {
reject(pluginResult.error);
} else if (pluginResult.then) {
pluginResult.then(resolve).catch(reject);
}
} else {
reject({ error: 'unexpected_error' });
}
pluginResult.then(resolve).catch(reject);
});
}

Expand Down

0 comments on commit 9074362

Please sign in to comment.