Skip to content

Instantly share code, notes, and snippets.

@Saturate
Last active December 11, 2015 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Saturate/4528496 to your computer and use it in GitHub Desktop.
Save Saturate/4528496 to your computer and use it in GitHub Desktop.
window.onerror = function(msg, url, line) {
var loggerUrl = "/log/js";
var parameters = "?description=" + escapemsg
+ "&url=" + escape(url)
+ "&line=" + escape(line)
+ "&parent_url=" + escape(document.location.href)
+ "&user_agent=" + escape(navigator.userAgent);
/* Send error to the server by loading this as a image url. It will work as a GET request */
new Image().src = loggerUrl + parameters;
};
// Not using image
window.onerror = function(msg, url, line)
{
if(encodeURIComponent) {
var req = new AjaxRequest();
var params = "msg=" + encodeURIComponent(msg) + '&url=' + encodeURIComponent(url) + "&line=" + line;
req.setMethod("POST");
return req.loadXMLDoc("/log/js/", params);
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment