Capture and Report JavaScript Errors With window.onerror

onerroris a special browser event that fires whenever an uncaught JavaScript error has been thrown. It’s one of the easiest ways to log client-side errors and report them to your servers. It’s also one of the major mechanisms by which Sentry’s client JavaScript integration (raven-js) works.
You listen to theonerrorevent by assigning a function to window.onerror: