Skip to content

Commit

Permalink
fix: gracefully handle read-only "column"-property of the Error class
Browse files Browse the repository at this point in the history
- this is the case in Safari starting with version 9.0
- see 07511e0
- also see #1285
  • Loading branch information
nknapp committed Jan 1, 2019
1 parent a7744f8 commit 90f4af5
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lib/handlebars/exception.js
Expand Up @@ -19,13 +19,28 @@ function Exception(message, node) {
this[errorProps[idx]] = tmp[errorProps[idx]];
}

/* istanbul ignore else */
if (Error.captureStackTrace) {
Error.captureStackTrace(this, Exception);
}

if (loc) {
this.lineNumber = line;
this.column = column;
try {
if (loc) {
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 */
}
}

Expand Down

0 comments on commit 90f4af5

Please sign in to comment.