2 const errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
4 function Exception(message, node) {
5 let loc = node && node.loc,
10 column = loc.start.column;
12 message += ' - ' + line + ':' + column;
15 let tmp = Error.prototype.constructor.call(this, message);
17 // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
18 for (let idx = 0; idx < errorProps.length; idx++) {
19 this[errorProps[idx]] = tmp[errorProps[idx]];
22 /* istanbul ignore else */
23 if (Error.captureStackTrace) {
24 Error.captureStackTrace(this, Exception);
29 this.lineNumber = line;
31 // Work around issue under safari where we can't directly set the column value
32 /* istanbul ignore next */
33 if (Object.defineProperty) {
34 Object.defineProperty(this, 'column', {value: column});
40 /* Ignore if the browser is very particular */
44 Exception.prototype = new Error();
46 export default Exception;