Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80698 views
1
2
var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
3
4
function Exception(message, node) {
5
var loc = node && node.loc,
6
line,
7
column;
8
if (loc) {
9
line = loc.start.line;
10
column = loc.start.column;
11
12
message += ' - ' + line + ':' + column;
13
}
14
15
var tmp = Error.prototype.constructor.call(this, message);
16
17
// Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
18
for (var idx = 0; idx < errorProps.length; idx++) {
19
this[errorProps[idx]] = tmp[errorProps[idx]];
20
}
21
22
if (loc) {
23
this.lineNumber = line;
24
this.column = column;
25
}
26
}
27
28
Exception.prototype = new Error();
29
30
export default Exception;
31
32