The JavaScript onerror Event
JavaScript has quite a few built-in events that handle various situations. One that can help quite a bit when debugging our web applications is the onerror event. Using the onerror event allows us to capture all the JavaScript errors that happen during runtime. This event returns three parameters that can be manipulated in any custom callback function that we define. The three parameters are the error message that was received, the URL of the file with the issue, and the line number in the file that is causing the error. For the most part, this event is useful but it can be quite vague at times, making sense only to someone who is intimately familiar with the code that is throwing the error.
In order to set up the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access