'Capacitor plugin stop responding after exception
I'm using ionic and capacitor v2.5 for creating a plugin
I'm using the following code for catching unhandled exception in the capacitor plugin
public void load() {
super.load();
try {
Thread
.setDefaultUncaughtExceptionHandler(
new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable e) {
PluginCall call = getSavedCall();
if (call != null) {
call.error("called failed:"+e.getMessage());
}
freeSavedCall();
}
});
} catch (SecurityException e) {
Log.e(Constants.TAG_MASTER,
"Could not set the Default Uncaught Exception Handler:"
+ e.getStackTrace());
}
}
my problem is that whenever there is an unhandled exception, the plugin stop to respond to calls from the ionic app.
The code operates as "expected" in a sense that gets the call from the method that throwed the exception and the call.error(..); is executed.
I can replicate that with the following code
public void foo(PluginCall call) {
saveCall(call);
throw new exception();
}
Any thoughts on why the plugin stops to respond after that?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
