Skip to content

Commit

Permalink
Include file name in SyntaxError message if present
Browse files Browse the repository at this point in the history
FIX: Mention the source file name in syntax error messages when given.
  • Loading branch information
Norbiros authored Jan 26, 2025
1 parent a707bfe commit 7b38623
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions acorn/src/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const pp = Parser.prototype
pp.raise = function(pos, message) {
let loc = getLineInfo(this.input, pos)
message += " (" + loc.line + ":" + loc.column + ")"
if (this.sourceFile) {
message += " in " + this.sourceFile
}
let err = new SyntaxError(message)
err.pos = pos; err.loc = loc; err.raisedAt = this.pos
throw err
Expand Down

0 comments on commit 7b38623

Please sign in to comment.