Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think the supposition is that the syntax errors are worked out of the JavaScript by the time you deploy it to customers. This is most likely intended to catch runtime errors from unanticipated conditions.

A `try/catch` is most expensive when used in a deep function called many times. Wrapping the typical "click" handler isn't going to cause performance issues. The biggest issue is that browsers have inconsistent support for stack and line info in a `try/catch` block.

Another options would be to use `window.onerror`. I've deployed apps that use the latter to report Javascript errors via the query string on an `<img>` element and it's been very useful.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: