Search code examples
javascriptcordovaruntime-erroronerror

window.onerror not being fired in cordova


I have placed this code on a cordova app:

window.onerror = function(error, script, line, column) {
    // code here
}

It triggers the Uncaught Reference Errors, but that's the only error that's triggered on Android devices.

Should I add something else?


Solution

  • Ok, I feel a little dumb.

    When I was testing and it didn't work, I was doing this from Chrome and using GapDebug.

    Well. Since the issues were being forced from the Chrome console, the window.onerror seemed not to be on scope, so it was not being called. When I simply broke the app from the code itself (instead of doing so from the console), it did work like a charm.

    This is just a warning for the next ones dealing with this!