include error.js

This commit is contained in:
j 2016-02-29 17:57:27 +05:30
parent 42e393b93f
commit a2a28a99d6
2 changed files with 20 additions and 0 deletions

View file

@ -11,6 +11,7 @@
<script type="text/javascript" src="js/app.js"></script> <script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/ox.extra.js"></script> <script type="text/javascript" src="js/ox.extra.js"></script>
<script type="text/javascript" src="js/dnd.js"></script> <script type="text/javascript" src="js/dnd.js"></script>
<script type="text/javascript" src="js/error.js"></script>
<link rel="stylesheet" href="css/styles.css" /> <link rel="stylesheet" href="css/styles.css" />
</head> </head>

19
js/error.js Normal file
View file

@ -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);
}
}