Skip to content

Commit 7b38623

Browse files
authored
Include file name in SyntaxError message if present
FIX: Mention the source file name in syntax error messages when given.
1 parent a707bfe commit 7b38623

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

acorn/src/location.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ const pp = Parser.prototype
1212
pp.raise = function(pos, message) {
1313
let loc = getLineInfo(this.input, pos)
1414
message += " (" + loc.line + ":" + loc.column + ")"
15+
if (this.sourceFile) {
16+
message += " in " + this.sourceFile
17+
}
1518
let err = new SyntaxError(message)
1619
err.pos = pos; err.loc = loc; err.raisedAt = this.pos
1720
throw err

0 commit comments

Comments
 (0)