Automagically wrap scripts in try...catch blocks to improve error reporting:
- use ResourceLoader::makeLoaderImplementScript() to wrap source code in a try...catch block which passes the exception to the error logger
- manipulate $, window etc. so that every top-scope call (event handlers, setTimeout etc) can be automatically wrapped in exception handling (probably a fair coverage could be achieved by decorating $.on, $.ready, $.ajax and window.setTimeout/setInterval).
- create a browser testing suite to make sure no grade-A browser is broken by replacing native functions like setTimout (or ensure others did this already - sinon.js maybe?)
This is an alternative to using window.onerror (and as such an alternative to working around its problems - T508, T512). This might turn out to be too fragile or impractical to be worth doing. (Also, it probably won't work in debug mode when scripts are not minified.)