从控制台隐藏错误和警告 [英] Hide errors and warnings from console

查看:404
本文介绍了从控制台隐藏错误和警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHP和其他语言中,有一些方法可以抑制错误/警告消息.

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

javascript或jquery中是否有一种方法可以防止将错误和警告写入控制台日志?

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

推荐答案

可以在一定程度上处理错误,但是如果您未处理错误,则错误会转到浏览器,并且您不能停止浏览器显示它.您可以通过编写代码以使错误最小化的方式编写代码,并尽可能使用try-catch来处理异常.

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)
{
}

这篇关于从控制台隐藏错误和警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆