From a2a28a99d6384f610d4291d9fce05439cabf939a Mon Sep 17 00:00:00 2001 From: j Date: Mon, 29 Feb 2016 17:57:27 +0530 Subject: [PATCH] include error.js --- index.html | 1 + js/error.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 js/error.js 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); + } +}