Catch error when application is not loading


I have a problem where I want to write some sort of plugin for Cordova that catches when the application isn’t loaded and then tries to load the application from another location. I tried to create a plugin and listen for an event (in onMessage function, with http error code 500) that the page didn’t successfully load. But I found out that the event was not sent to that function. Then I found “onReceivedHttpError” but I can’t find any version of Cordova that implements this function and pass it on to the Plugin Manager.

I need to know if I got a 500 response when trying to load the application and if that happens redirect to another page.

How can I do this?