I’d like to catch all client-side JavaScript errors on our site and log them. What are some best practices for doing this?
Thoughts:
- I can easily add a
/log/handler to our webapp, parse GET/POST parameters and use our existing logging system on the server-side. Is that too obvious? - Does
window.onerrorwork everywhere? What if an error occurs in the handler? - Should I attach an
<img>tag to the page or make an XmlHttpRequest? What if the XHR fails? - What about broken images and jQuery Ajax failures — can I catch those too?
All suggestions made by Jbecwar and dgvid are cool, I would add: