Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throw new Error in a Nunjucks filter results in unhandled promise rejection #3295

Closed
zachleat opened this issue May 25, 2024 · 3 comments
Closed
Labels

Comments

@zachleat
Copy link
Member

export default function(eleventyConfig) {
  eleventyConfig.addFilter("test", () => throw new Error("Invalid!"));
};

Nunjucks template:

{{ "hello" | test }}
@zachleat zachleat added the bug label May 25, 2024
@zachleat zachleat added this to the Eleventy 3.0.0 milestone May 25, 2024
@zachleat
Copy link
Member Author

@zachleat
Copy link
Member Author

Test case build results:

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble rendering njk template ./index.njk (via TemplateContentRenderError)
[11ty] 2. (./index.njk)
[11ty]   Error: Invalid! (via Template render error)
[11ty] 
[11ty] Original error stack trace: Template render error: (./index.njk)
[11ty]   Error: Invalid!
[11ty]     at Object._prettifyError (/Users/zachleat/Code/eleventy/node_modules/nunjucks/src/lib.js:32:11)
[11ty]     at /Users/zachleat/Code/eleventy/node_modules/nunjucks/src/environment.js:464:19
[11ty]     at Template.root [as rootRenderFunc] (eval at _compile (/Users/zachleat/Code/eleventy/node_modules/nunjucks/src/environment.js:527:18), <anonymous>:18:3)
[11ty]     at Template.render (/Users/zachleat/Code/eleventy/node_modules/nunjucks/src/environment.js:454:10)
[11ty]     at file:///Users/zachleat/Code/eleventy/src/Engines/Nunjucks.js:415:10
[11ty]     at new Promise (<anonymous>)
[11ty]     at file:///Users/zachleat/Code/eleventy/src/Engines/Nunjucks.js:414:11
[11ty]     at Template._render (file:///Users/zachleat/Code/eleventy/src/TemplateContent.js:594:25)
[11ty]     at async Template.renderPageEntryWithoutLayout (file:///Users/zachleat/Code/eleventy/src/Template.js:414:25)
[11ty]     at async TemplateMap.populateContentDataInMap (file:///Users/zachleat/Code/eleventy/src/TemplateMap.js:573:7)
[11ty] Wrote 0 files in 0.03 seconds (v3.0.0-alpha.14)

@zachleat
Copy link
Member Author

Adding more information about the specific filter that failed:

~/Temp/eleventy-3295 ᐅ npx @11ty/eleventy
[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble rendering njk template ./index.njk (via TemplateContentRenderError)
[11ty] 2. (./index.njk)
[11ty]   EleventyFilterError: Error in Nunjucks filter `test` (./index.njk) (via Template render error)
[11ty] 3. Invalid! (via Template render error)
[11ty] 
[11ty] Original error stack trace: Error: Invalid!
[11ty]     at Context.<anonymous> (file:///Users/zachleat/Temp/eleventy-3295/eleventy.config.js:3:9)
[11ty]     at Context.<anonymous> (file:///Users/zachleat/Code/eleventy/src/UserConfig.js:293:23)
[11ty]     at Context.<anonymous> (file:///Users/zachleat/Code/eleventy/src/Benchmark/BenchmarkGroup.js:35:23)
[11ty]     at Context.<anonymous> (file:///Users/zachleat/Code/eleventy/src/Engines/Nunjucks.js:112:15)
[11ty]     at Template.root [as rootRenderFunc] (eval at _compile (/Users/zachleat/Code/eleventy/node_modules/nunjucks/src/environment.js:527:18), <anonymous>:10:55)
[11ty]     at Template.render (/Users/zachleat/Code/eleventy/node_modules/nunjucks/src/environment.js:454:10)
[11ty]     at file:///Users/zachleat/Code/eleventy/src/Engines/Nunjucks.js:423:10
[11ty]     at new Promise (<anonymous>)
[11ty]     at file:///Users/zachleat/Code/eleventy/src/Engines/Nunjucks.js:422:11
[11ty]     at Template._render (file:///Users/zachleat/Code/eleventy/src/TemplateContent.js:594:25)
[11ty] Wrote 0 files in 0.03 seconds (v3.0.0-alpha.14)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant