Coder of Salvation™   — programming / opensource / console / minimal

Javascript on productionservers


A client calls because the system is 'not workable'. You check, but cannot find anything strange. So, we enter the voodoo-area: it might be a specific browserbug, temporary bug, etc.


You don't want bugs which are not reproducable.

Ideal situation

You discovered the bug, and tell the client it has already been fixed as soon as he calls.

Possible solution

Usage of:

Javascript Code

// 23-12-2009 Coder of Salvation start from scratch
var error = {
  url: "/error",
  ro:  (navigator.appName == 'Microsoft Internet Explorer') ?
        new ActiveXObject('Microsoft.XMLHTTP') : ro = new XMLHttpRequest(),
  init: function(){
    // assign own handler
    window.onerror = error.handleError;
   * advanced: a full error handler
  handleError: function(err, url, line) {
    var log = 'err='          +err+
              '&url='          +url+
              '&line='         +line+
              '&href='         +document.location.href+
              '&pathname='     +document.location.pathname+
              '&appCodeName='  +navigator.appCodeName+
              '&appName='      +navigator.appName+
              '&appVersion='   +navigator.appVersion+
              '&platform='     +navigator.platform+
              '&userAgent='    +navigator.userAgent; 'post', error.url , true);'Content-Type', 'application/x-www-form-urlencoded'); log );
    return true; // error is handled

The above could be a good starting point, you might even want to wrap your whole code into an exception-block. It might also be a good idea to see if your javascriptframework supports something similar.

PHP Code

// not tested, but good as a start
print_r( $_GET );
$out = ob_get_contents();
mail( "", "your subject (error)", $message );

comments powered by Disqus

All rights reserved by Leon van Kammen under this license