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, code is:
<HTML>
<HEAD>
<script language='javascript'>
window.onerror = function (em, url, ln) {
alert(em + ", " + url + ", " + ln);
return false;
}
function fGo() {
try
{
var a = b; // error here : b not defined
}
catch (e)
{
throw e;
}
}
</script>
</HEAD>
<BODY>
<button onclick='fGo()'>GO</button>
</BODY>
</HTML>
I'm testing on chrome, by the way. Developer console registers the uncaught exception, but the alert() in window.onerror does not appear.