Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide errors and warnings from console

In PHP and other languages there are ways to suppress error/warning messages.

Is there a way in javascript or jquery to prevent errors and warnings from being written to the console log?

like image 858
StudioTime Avatar asked Feb 04 '14 09:02

StudioTime


People also ask

How do I hide errors in console?

console. clear(); is good option to hide the console error because some time on running site we don't want to show error so we hide them in PHP.

How do I hide warnings in console react?

But if you want to hide all warnings in the production, you need to use the production version of React or set the environment to production in your webpack configuration". This is possible by using DefinePlugin plugin. Essentially what this plugin does is to replace all instances of process.

How do I hide console errors in Chrome?

# Option to hide CORS errors in the Console In the Console, click on the Settings icon and uncheck the Show CORS errors in console checkbox.

Should I use console error or console log?

console. error is used to output error messages while console. log is the most commonly used console method and is used to log out all sorts of objects or messages. In case of some error browser automatically output the relevant error message while you have to manually log out objects using console.


2 Answers

You can handle errors to some extent but if error is not handled by you then it goes to browser and you can not stop browser showing it. You can write code in such a way that you get minimum error and using try-catch where possible to handle the exceptions.

try
{
    //statements suspected to throw exception.
}
catch(e)
{
}
like image 71
Adil Avatar answered Sep 25 '22 15:09

Adil


A dirty way to hide all Javascript console warnings is by overriding the console object's warn method:

console.warn = () => {};

Obviously, it also works with other console methods

like image 20
akmalzamri Avatar answered Sep 22 '22 15:09

akmalzamri