Skip to content

Instantly share code, notes, and snippets.

@rhrn
Last active April 5, 2017 10:18
Show Gist options
  • Save rhrn/4134903 to your computer and use it in GitHub Desktop.
Save rhrn/4134903 to your computer and use it in GitHub Desktop.
Send javascript errors to server
var errorLog = function errorLog(msg, url, line) {
var i = document.createElement('img');
i.src = '/error/log?msg=' + encodeURIComponent(msg) + '&url=' + encodeURIComponent(url) + '&line=' + encodeURIComponent(line);
};
window.onerror = errorLog;
var errorLog = function errorLog(msg, url, line) {
var thisUrl = '/error/log?msg=' + encodeURIComponent(msg) + '&url=' + encodeURIComponent(url) + '&line=' + encodeURIComponent(line);
xhr = new XMLHttpRequest();
xhr.open("GET", thisUrl, true);
xhr.send(null);
};
window.onerror = errorLog;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment