In both Chrome and Firefox, it is possible to suppress exceptions, but unfortunately, this is not the case with Internet Explorer (IE).
window.addEventListener("error", function errorHandler(event) {
console.log("exception should be suppressed and not shown in the console");
event.preventDefault();
});
throw "suppress me";
and
window.onerror = function errorHandler() {
console.log("exception should be suppressed and not shown in the console");
return true;
};
throw "suppress me";
You can experiment with these methods
https://jsfiddle.net/9uj4xm3g/4/
https://jsfiddle.net/gv0pvy3b/3/
Any thoughts on this?
UPD:
I forgot to mention what I mean by suppressing. I want to be able to completely hide the SCRIPT5022 message by marking an error as handled.
https://i.sstatic.net/Pvozi.png
As stated in https://msdn.microsoft.com/en-us/library/cc197053.aspx
To suppress the default Windows Internet Explorer error message for the window event, set the returnValue property of the event object to true or simply return true in Microsoft JScript.
However, as you can see, this approach does not resolve errors logged to the console