Skip to content

Instantly share code, notes, and snippets.

@ManInTheBox
Created September 28, 2012 15:47
Show Gist options
  • Save ManInTheBox/3800622 to your computer and use it in GitHub Desktop.
Save ManInTheBox/3800622 to your computer and use it in GitHub Desktop.
onerror handler
(function() {
var oldErrorHandler = window.onerror;
window.onerror = function(errorMsg, file, line) {
var e = encodeURIComponent;
if (oldErrorHandler) {
oldErrorHandler(errorMsg, file, line);
}
(new Image()).src = '/njl/log?msg=' + e(errorMsg) + '&level=error' + '&context[file]=' + e(file) + '&context[line]=' + e(line) + '&context[browser]=' + e(navigator.userAgent) + '&context[page]=' + e(document.location.href);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment