From 345827665684a0fff2523f127c5b2b689b09d08a Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Tue, 3 Mar 2020 12:39:20 +0100 Subject: [PATCH] feat(android): Allow plugin methods to crash --- .../src/main/java/com/getcapacitor/Bridge.java | 5 +++-- .../src/main/java/com/getcapacitor/PluginHandle.java | 10 ++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/android/capacitor/src/main/java/com/getcapacitor/Bridge.java b/android/capacitor/src/main/java/com/getcapacitor/Bridge.java index 7368de89a8..f8fa790236 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/Bridge.java +++ b/android/capacitor/src/main/java/com/getcapacitor/Bridge.java @@ -522,10 +522,11 @@ public void run() { if (call.isSaved()) { saveCall(call); } - } catch(PluginLoadException | InvalidPluginMethodException | PluginInvocationException ex) { + } catch(PluginLoadException | InvalidPluginMethodException ex) { Log.e(LOG_TAG, "Unable to execute plugin method", ex); - } catch(Exception ex) { + } catch (Exception ex) { Log.e(LOG_TAG, "Serious error executing plugin", ex); + throw new RuntimeException(ex); } } }; diff --git a/android/capacitor/src/main/java/com/getcapacitor/PluginHandle.java b/android/capacitor/src/main/java/com/getcapacitor/PluginHandle.java index 6f8bfedfb9..3f960656a4 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/PluginHandle.java +++ b/android/capacitor/src/main/java/com/getcapacitor/PluginHandle.java @@ -84,7 +84,8 @@ public Plugin load() throws PluginLoadException { */ public void invoke(String methodName, PluginCall call) throws PluginLoadException, InvalidPluginMethodException, - PluginInvocationException { + InvocationTargetException, + IllegalAccessException { if(this.instance == null) { // Can throw PluginLoadException this.load(); @@ -95,11 +96,8 @@ public void invoke(String methodName, PluginCall call) throws PluginLoadExceptio throw new InvalidPluginMethodException("No method " + methodName + " found for plugin " + pluginClass.getName()); } - try { - methodMeta.getMethod().invoke(this.instance, call); - } catch(InvocationTargetException | IllegalAccessException ex) { - throw new PluginInvocationException("Unable to invoke method " + methodName + " on plugin " + pluginClass.getName(), ex); - } + methodMeta.getMethod().invoke(this.instance, call); + } /**