开发者

Add global try/catch to JavaScript

Is there some way to wrap the entire page in a try/catch, so that I can catch any error from any script that 开发者_C百科is executing?


Use window.onerror instead of a big try/catch.

You could actually do some useful things in the error handler, like posting the error information to your server so you know when things are breaking on your page.


Turn on the debugger and break on error.

You don't want to catch every error in the entire page on production code. That's horrible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜