admin管理员组文章数量:1334342
My web page is catching errors with window.onerror
and than sends the error to the server for logging. This is working well. However, I stopped seeing the errors on Chrome and Firefox console logs. This makes debugging the application more difficult. Is there any way I can keep using window.onerror
yet see the error logs on the console without writing it myself on the onerror
? When Chrome is writing the error to the console (if onerror
is not used) the stacktrace and navigation to the error source are really helpful.
My web page is catching errors with window.onerror
and than sends the error to the server for logging. This is working well. However, I stopped seeing the errors on Chrome and Firefox console logs. This makes debugging the application more difficult. Is there any way I can keep using window.onerror
yet see the error logs on the console without writing it myself on the onerror
? When Chrome is writing the error to the console (if onerror
is not used) the stacktrace and navigation to the error source are really helpful.
1 Answer
Reset to default 9You have to return false
at the end of the error handler to let the default error handler (which logs to the console) run.
window.onerror = function myErrorHandler(errorMsg, url, lineNumber) {
//Do some of your ajax requests or whatever
return false;
}
Out of MDN:
When the function returns true, this prevents the firing of the default event handler.
https://developer.mozilla/en-US/docs/Web/API/GlobalEventHandlers.onerror
本文标签: javascriptCatch errors with windowonerror yet see errors on consoleStack Overflow
版权声明:本文标题:javascript - Catch errors with window.onerror yet see errors on console - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742369593a2461970.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论