fix: gracefully handle read-only "column"-property of the Error class

- this is the case in Safari starting with version 9.0
- see 07511e0379dbdeea78f407065b0a3134a79a38a6
- also see #1285
This commit is contained in:
Nils Knappmeier
2019-01-02 00:29:18 +01:00
committed by Nils Knappmeier
parent d207ad056a
commit 725986da22
+18 -3
View File
@@ -19,13 +19,28 @@ function Exception(message, node) {
this[errorProps[idx]] = tmp[errorProps[idx]]; this[errorProps[idx]] = tmp[errorProps[idx]];
} }
/* istanbul ignore else */
if (Error.captureStackTrace) { if (Error.captureStackTrace) {
Error.captureStackTrace(this, Exception); Error.captureStackTrace(this, Exception);
} }
if (loc) { try {
this.lineNumber = line; if (loc) {
this.column = column; this.lineNumber = line;
// Work around issue under safari where we can't directly set the column value
/* istanbul ignore next */
if (Object.defineProperty) {
Object.defineProperty(this, 'column', {
value: column,
enumerable: true
});
} else {
this.column = column;
}
}
} catch (nop) {
/* Ignore if the browser is very particular */
} }
} }