Search code examples
androidcordovacordova-pluginshybrid-mobile-appcordova-android

Custom Exception Handler for Cordova plugin


I developed an Exception handler for android apps and it is working fine inside android-studio native projects.

Now I am developing a cordova plugin and I want to add my Exception Handler to catch all the uncaught exceptions, whether they are inside the plugin or in some other native code.

The problem I am facing is, the PluginManager in CordovaLib catches all the exception. I want my Exception handler class to catch the exceptions, not PluginManager class. Does anyone know how to do it ?

Any help would be appreciated.

Note : I am usign Cordova 8.0.0


Solution

  • You can write a javascript function to handle all the JS Exceptions thrown before it goes down the stack to PluginManager. It will be a little tricky but I did it successfully using javascript.