-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathCore.Error.js
More file actions
76 lines (72 loc) · 2.51 KB
/
Core.Error.js
File metadata and controls
76 lines (72 loc) · 2.51 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*globals Core*/
(function () {
var coreError = function (ajax, window) {
// window.onerror = function (msg, url, num) {
// if (window.debug !== undefined && window.debug === false) {
// Core.Error.log(1, msg + ';' + url + ';' + num);
// return true;
// }
// };
var isFunction = function (object) {
return typeof (object) == 'function';
};
return {
log: function (severity, message) {
var i, arraylength;
if (Core.Ajax !== undefined) {
try {
var trace = printStackTrace();
//get any urls ready for the http request
for (i = 0, arraylength = trace.length; i < arraylength; i++) {
trace[i] = encodeURI(trace[i]);
}
ajax.request({
name: "errorLog",
data: { severity: severity, message: message, stackTrace: trace }
});
}
catch (ex) {
//TODO: can't communicate with server
}
}
},
consoleLog: function (message) {
if (window.console !== undefined) {
if (window.console.log !== undefined && isFunction(window.console.log) === true) {
window.console.log(message);
}
}
},
sanitise: function sanitise(instance) {
var method, name;
if (window.debug === false) {
for (name in instance) {
method = instance[name];
if (typeof method === "function") {
instance[name] = (function (name, method) {
return function () {
//try {
return method.apply(this, arguments);
//}
//catch (ex) {
//Core.Error.log(1, name + "(): " + ex.message);
//}
};
})(name, method);
}
}
}
return instance;
}
};
};
if (typeof define === "function" && define.amd) {
define("Core.Error", ["Core", "Core.Ajax"], function (core, ajax) {
core.Error = coreError(ajax, window);
return core.Error;
});
}
else {
Core.Error = coreError(Core.Ajax, window);
}
})();