How do I overwrite the global Exception handler in javascript so that it becomes the top level handler for all uncaught exceptions?
EDIT: window.onerror didnt work, cod
Chrome Support for window.onerror
Current Google Documentation for window.onerror
As of 2013 Chrome supports the window.onerror
. (I have version 25 comments imply earlier versions as well)
What I did was to wrap JQuery using currying to create a proxy that always does a try...catch
in the JQuery functions.
I use it in www.js-analytics.com, however the solution only holds for JQuery scripts.
Before 2013 Google Chrome didn't support window.onerror
, apparently it wasn't implemented in WebKit.
window.onerror = function(errorMsg, url, lineNumber) {
// code to run when error has occured on page
}
Perhaps you're looking for window.onerror Not sure whether this is available on all browsers.