speedtrans/js/error.js
2016-02-29 17:59:16 +05:30

19 lines
654 B
JavaScript

window.onerror = function(error, url, line, column, errorObj) {
if (error == 'TypeError: Attempted to assign to readonly property.') {
return;
}
try {
var stack = (errorObj && errorObj.stack) || "(no stack trace available)",
url = document.location.pathname + ' at ' + url,
text = url + "\n\nLine:" + line + "\n\n" + error + "\n\n" + stack;
logError(text);
} catch(e) {}
};
function logError(error) {
if (document.location.hostname == 'speedtrans.pad.ma') {
var request = new XMLHttpRequest();
request.open('post', '/error', true);
request.send(error);
}
}