在$ HTTP错误角避免控制台跟踪 [英] Angular avoid Console trace on $http error
问题描述
在我的应用程序正在使用REST API来获取我的数据。
如果发这样的恳求
In my application I am using a REST api to get my data. If a send a request like this
$http.get('api/entity/' + $scope.entityId).success(/* DO STUFF */).error(/* DO STUFF */)
在服务,如果ENTITYID不存在,我返回404。
在误差函数我赶上使用状态(第二个参数)和行为上以适当的方式吧。
In the service, if the entityId does not exist I return a 404. In the error function I catch it using the status (second parameter) and act on it in a proper way.
我被,如果角度抛出一个异常,污染JavaScript控制台的事实恼火。这似乎在Angular.js发生:8165
I'm being annoyed by the fact that angular if throwing an exception and pollutes the javascript console. It seem to happen on Angular.js:8165
这有什么办法可以告诉角度,我是一个长大了开发人员,我会处理他所认为的错误自己在一个很好的方式?
It there any way to tell angular that I'm a grown up developer and I will handle what he sees as an error myself in a nice way?
在换句话说,我可以告诉角度可以不输出废话?
In other words, can I tell angular to not output that crap?
谢谢,
推荐答案
这是浏览器的功能,而不是做记录AngularJS的一部分。下面是这个页面的控制台示例:
This is your browser's functionality, and not a part of AngularJS that does the logging. Here's a sample from the console of this page:
您可以看到它记录你在问题的评论链接完全相同的错误消息,并且确实是指着一个部分来源$ C $ C ,但我没有添加任何记录语句。
You can see it logs the exact same error message as you linked in the question's comment, and is indeed pointing to a part in the source code, but I didn't add any logging statements.
你能做的最好的事情就是按照这个答案和过滤器添加到控制台。
The best thing you can do is follow this answer and add a filter to the console.
这篇关于在$ HTTP错误角避免控制台跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!