Google Chrome, Firefox, and other browsers have a developer console to show errors. Are these the same errors that are triggered by window.onerror
?
The Chrome developer console is a superset of the information that is made available to window.onerror
. The developer console will show JavaScript errors, security errors, CSS errors, deprecation warnings, and many other internal faults in rendering the document.
window.onerror
is only unhandled global JavaScript errors.
Another important difference is that the Developer Console will show the real, original error information whereas window.onerror
might obfuscate the error message to "Script Error" if the error violates the Same Origin Policy.
The Chrome Developer console is a better set of information during development. Once you release your app, you should continue to trap and record errors from window.onerror
so that you can be sure to know when your users run into problems. The browser landscape is constantly changing, and you should know when something starts breaking. There are some good tools to help you do this automatically, like TrackJS. Disclosure: I am one of the founding developers of TrackJS, so I've fixed a lot of js errors :)
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