chore(): replace try/catch with better approach (#956)

* chore(): replace try/catch with better approach

* optimize last commit
This commit is contained in:
Ibby Hadeed 2017-01-10 07:06:44 -05:00 committed by GitHub
parent 77d6308bca
commit 5981622f3a

View File

@ -108,7 +108,7 @@ function callCordovaPlugin(pluginObj: any, methodName: string, args: any[], opts
let pluginInstance = getPlugin(pluginObj.pluginRef);
if (!pluginInstance) {
if (!pluginInstance || !pluginInstance.hasOwnProperty(methodName)) {
// Do this check in here in the case that the Web API for this plugin is available (for example, Geolocation).
if (!window.cordova) {
cordovaWarn(pluginObj.pluginName, methodName);
@ -123,16 +123,7 @@ function callCordovaPlugin(pluginObj: any, methodName: string, args: any[], opts
};
}
// TODO: Illegal invocation needs window context
let value;
try {
value = get(window, pluginObj.pluginRef)[methodName].apply(pluginInstance, args);
} catch (e) {
value = {
error: 'cordova_not_available'
};
}
return value;
return pluginInstance[methodName].apply(pluginInstance, args);
}
/**