Skip to content

Commit

Permalink
feat(android): Allow plugin methods to crash (#2512)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Mar 4, 2020
1 parent 08a2ebc commit 253cdc9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 3 additions & 2 deletions android/capacitor/src/main/java/com/getcapacitor/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);

}

/**
Expand Down

0 comments on commit 253cdc9

Please sign in to comment.