Javascript Global Error Handler

Today i’have created a simple class to log in the backend the javascript error, so i can have a real time monitoring of how error appear to the users.

We can use a window.onerror and the addEventListener rewrite.

Window.onerror has been available in most browser, but the argument that are passed on each browser are different:

BrowserMessageURLlineNocolNoerrorObj
Firefox
Chrome
Edge
IE 11
IE 10
IE 9, 8
Safari 10 and up
Safari 9
Android Browser 4.4

This is my class with a _wrap function, and a SendError that trasmit the data on the backend

In the message we put the stacktrace.
To use it at the init of your application:
let handlerError = new HandlerError();

Write to me if you have some suggestion to improve it.

2
Leave a Reply

avatar
2 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
Webdesignvalley.comminnesota web design Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
minnesota web design
Guest

Informative post,It is useful for me to clear my doubts.I hope others also like the information you gave in your blog.

Webdesignvalley.com
Guest

These are really amazing and valuable websites you have share with us. Thanks for the informative post. Keep posting like these information.