I have one line of code that is throwing an error that I don’t care about. I need to hide it from the console. I don’t want to use a custom error handler and return false, because I want to see all other errors.
I’ve tried a try / catch, but the error still shows up in the console:
try{
//the erroneous line of code
}catch(err){ }
I’ve also tried fiddling window.onerror right before the erroneous line, and fiddling it back right after, and the error still shows up in this case as well:
window.onerror = function(){ return false; }
//erroneous line of code
window.onerror = function(){ return true; }
Any help would be appreciated.
try catch is the one to use
I only get
a is not defined
in the console in my fiddle
I do not get the SECOND error in the console. Not even after commenting out the first error just in case it possibly blocked further processing.