Skip to content

Error message for syntax error missing location in 4.2.1+ #1562

@dougwilson

Description

@dougwilson

It seems like there was a change (I assume from looking at the commits the change was in the auto generated code that is not checked in) where the err.stack no longer includes the err.message, which explains what the syntax error is. Most places that log an error that want a stack trace will console.log(err.stack) assuming that err.message is included on the first line, and it was though the 4.2.0 release, no with 4.2.1+ it is missing.

Example code to reproduce:

node -pe 'require("handlebars").parse("{{")'

In 4.2.0 and prior versions, that produces the following:

$ node -pe 'require("handlebars").parse("{{")'
node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:267
            throw new Error(str);
            ^

Error: Parse error on line 1:
{{
--^
Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'EOF'
    at Object.parseError (node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:267:19)
    at Object.parse (node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:336:30)
    at HandlebarsEnvironment.parse (node_modules/handlebars/dist/cjs/handlebars/compiler/base.js:46:43)
    at [eval]:1:23
    at ContextifyScript.Script.runInThisContext (vm.js:25:33)
    at Object.runInThisContext (vm.js:97:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:577:32)
    at evalScript (bootstrap_node.js:358:27)
    at run (bootstrap_node.js:133:11)

But in 4.2.1+ it produces the following:

$ node -pe 'require("handlebars").parse("{{")'
Error
    at Object.parseError (node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:278:41)
    at Object.parse (node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:365:26)
    at HandlebarsEnvironment.parse (node_modules/handlebars/dist/cjs/handlebars/compiler/base.js:46:43)
    at [eval]:1:23
    at ContextifyScript.Script.runInThisContext (vm.js:25:33)
    at Object.runInThisContext (vm.js:97:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:577:32)
    at evalScript (bootstrap_node.js:358:27)
    at run (bootstrap_node.js:133:11)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions