From 54d1a9891beca23d229ff3b064110f3de6c86da2 Mon Sep 17 00:00:00 2001 From: Ibby Date: Sat, 7 Jan 2017 05:26:38 -0500 Subject: [PATCH] chore(): add try/catch for callCordovaPlugin method closes #882 --- src/plugins/plugin.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/plugin.ts b/src/plugins/plugin.ts index a677720ee..09ec79bbe 100644 --- a/src/plugins/plugin.ts +++ b/src/plugins/plugin.ts @@ -124,7 +124,15 @@ function callCordovaPlugin(pluginObj: any, methodName: string, args: any[], opts } // TODO: Illegal invocation needs window context - return get(window, pluginObj.pluginRef)[methodName].apply(pluginInstance, args); + let value; + try { + value = get(window, pluginObj.pluginRef)[methodName].apply(pluginInstance, args); + } catch (e) { + value = { + error: 'cordova_not_available' + } + } + return value; } /**