I need a way to log all Javascript errors that may happen in a document. Obviously, an Ajax call to the logging script is no problem, but the window.onerror event doesn't fire for errors inside functions or in some other cases where the browser or web developer toolbar would report an error.
I'd rather not use try/catch because there's a lot of code in many places and I'd like a document-wide solution that would report all Javascript errors.
Is this even possible? I see so many high profile sites with Javascript errors, so obviously many developers either don't care or don't know about the errors.
First, sorry if I misunderstood your question and your qualifications.
Seems to be you are not familliar with DeveloperTools, and you better should be : ) For example, in Chrome you can open DeveloperTools by pressing F12 or Ctrl+Shift+J. All your previous and upcoming JavaScript errors will be displayed in the Console tab as they occur.
It is actually possible to do some automatic try-catch insertion, in a way where you do not need to alter your code. It's not easy.
You could try my project Muscula, that logs JavaScript errors with try-catch insertion and falls back on onerror when it's not possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With