mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-21 00:23:00 +08:00
chore(): replace try/catch with better approach (#956)
* chore(): replace try/catch with better approach * optimize last commit
This commit is contained in:
parent
77d6308bca
commit
5981622f3a
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user