diff --git a/index.html b/index.html index 092cb21..06dba3d 100644 --- a/index.html +++ b/index.html @@ -11,6 +11,7 @@ + diff --git a/js/error.js b/js/error.js new file mode 100644 index 0000000..fb8863c --- /dev/null +++ b/js/error.js @@ -0,0 +1,19 @@ +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); + } +}