-
Notifications
You must be signed in to change notification settings - Fork 2
/
error.js
48 lines (38 loc) · 1.53 KB
/
error.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(function () {
var errorCount = 0,
loggingURL = 'http://korowaj.com/vocavoca/error.php';
window.onerror = function (errorMessage, fileName, lineNumber) {
var whiteList = [];
//JS errors like to cascade, we do not want all of them
//but just the first one
if (!errorCount) {
errorCount++;
var gather = {
event: ['screenLeft', 'screenTop'],
screen: ['width', 'height', 'availWidth', 'availHeight'],
navigator: ['systemLanguage', 'userLanguage', 'language', 'userAgent'],
location: ['href'],
history: ['length']
};
var ret = {
errorMessage: errorMessage,
fileName: fileName,
lineNumber: lineNumber
}
for (var namespace in gather) {
if (typeof this[namespace] !== 'undefined') {
ret[namespace] = {}
for (var i = 0, l = gather[namespace].length; i < l; i++) {
if (typeof this[namespace][gather[namespace][i]] !== 'undefined') {
ret[namespace][gather[namespace][i]] = this[namespace][gather[namespace][i]];
}
}
}
}
var errorLogEntry = JSON.stringify(ret);
location.pathname.indexOf('test') && alert(errorLogEntry)
}
//returning true will cause the error be caught
return true;
};
})();