Reporting javascript errors to the server

In every web application that intensivly uses javascript: errors may occur !
Since I’m not able to fully-test my web-application each time a modification is made, I decided to report javascript
errors to the server. It proved to be very useful to detect bugs very quickly.

Here’s an example on how to do so with YUI :

window.onerror = function(msg, href, lineNo) {
var postData = ‘msg=’+msg+’&file=’+href+’&line=’+
YAHOO.util.Connect.asyncRequest(‘POST’, ‘report_error.php’,
{ success: function(o){}, failure: function(o){} }, postData);

I just added “navigator.userAgent” to the parameters of window.onerror, so you know
which browser generated the error.


comments powered by Disqus
Copyright © 2000-2015 - Eric Abouaf - Powered by Hexo