forked from stacktracejs/stacktrace.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptionLab.js
More file actions
38 lines (35 loc) · 756 Bytes
/
ExceptionLab.js
File metadata and controls
38 lines (35 loc) · 756 Bytes
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
function createException() {
return ((function(x) {
try {
x.undef();
} catch (ex) {
return ex;
}
})(null));
}
function printProp(prop, value) {
if (typeof value === "string") {
value = '"' + value.replace(/\"/g, '\\"').replace(/\r/g, "\\r").replace(/\n/g, '\\n" +\n "') + '"';
}
return prop + ': ' + value;
}
function getExceptionProps(ex) {
var prop, props = [], obj = {
message: true,
name: true,
stack: true,
stacktrace: true,
'arguments': true
};
// find enumerable properties
for (prop in ex) {
obj[prop] = true;
}
for (prop in obj) {
var value = ex[prop];
if (typeof value !== "undefined") {
props.push(printProp(prop, value));
}
}
return props;
}