I have a custom exception class which I'm using for a particular situation. It could be thrown from anywhere so try/catch isn't really practical.
throw new CustomException;
I want to catch this error in window.onerror and filter it out, which works fine in most browsers I've tested so far.
var window_onerror = window.onerror || function() {return false;};
window.onerror = function(message, url, line) {
if (message.match(CustomException.prototype.name)) {
return true;
} else {
return window_onerror(message, url, line);
}
};
However, in IE the window.onerror function receives Exception thrown and not caught
instead of my custom exception.