send client side javascript errors to the server

pull/87/merge
Peter 'Pita' Martischka 2011-08-17 19:24:44 +01:00
parent b58bdb4e4d
commit c2457e06d8
2 changed files with 22 additions and 0 deletions

View File

@ -312,6 +312,16 @@ async.waterfall([
});
});
//The Etherpad client side sends information about client side javscript errors
app.post('/jserror', function(req, res)
{
new formidable.IncomingForm().parse(req, function(err, fields, files)
{
console.error("CLIENT SIDE JAVASCRIPT ERROR: " + fields.errorInfo);
res.end("OK");
});
});
//serve index.html under /
app.get('/', function(req, res)
{

View File

@ -461,3 +461,15 @@ var padutils = {
});
}
};
//send javascript errors to the server
window.onerror = function test (msg, url, linenumber)
{
var errObj = {errorInfo: JSON.stringify({msg: msg, url: url, linenumber: linenumber, userAgent: navigator.userAgent})};
var loc = document.location;
var url = loc.protocol + "//" + loc.hostname + ":" + loc.port + "/" + loc.pathname.substr(1, loc.pathname.indexOf("/p/")) + "jserror";
$.post(url, errObj);
return false;
};