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