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.
精彩评论