I find it really hard to decipher the error messages generated by the CLI. When I run DEBUG mode using the npm debug module as suggested in the docs, all I get is a more verbose version of exactly the same error.
It doesn't for example tell me useful things like
Also the line and col given seems incorrect because when I reference that it doesn't seem to match anything - I'm guessing that's because I'm looking in the wrong file, because I don't know where to look based on the output.
Error: slugify: string argument expected (Template render error):
Template render error: (unknown path) [Line 8, Column 3]
Error: slugify: string argument expected
at Object._prettifyError (/Users/df/Sites/radiologymasters-11ty/node_modules/nunjucks/src/lib.js:36:11)
at /Users/df/Sites/radiologymasters-11ty/node_modules/nunjucks/src/environment.js:567:19
at eval (eval at _compile (/Users/df/Sites/radiologymasters-11ty/node_modules/nunjucks/src/environment.js:637:18), <anonymous>:60:12)
at b_main (eval at _compile (/Users/df/Sites/radiologymasters-11ty/node_modules/nunjucks/src/environment.js:637:18), <anonymous>:184:3)
at eval (eval at _compile (/Users/df/Sites/radiologymasters-11ty/node_modules/nunjucks/src/environment.js:637:18), <anonymous>:59:83)
at eval (eval at _compile (/Users/df/Sites/radiologymasters-11ty/node_modules/nunjucks/src/environment.js:637:18), <anonymous>:56:1)
at fn (/Users/df/Sites/radiologymasters-11ty/node_modules/a-sync-waterfall/index.js:26:24)
at /Users/df/Sites/radiologymasters-11ty/node_modules/a-sync-waterfall/index.js:66:22
at executeSync (/Users/df/Sites/radiologymasters-11ty/node_modules/a-sync-waterfall/index.js:8:15)
at /Users/df/Sites/radiologymasters-11ty/node_modules/a-sync-waterfall/index.js:65:11
This is the error code I'm trying to track
OK so I worked out where my own error came from...
My template was trying to slugify (Eleventy built in filter) a field which did not exist in some of the entries but did in others... that's why the error was somewhat unpredictable and also why it didn't cause the whole site build to fail.
My conclusion remains the same which is that it would be super useful if the CLI could at least output the filename of the template (or partial) it was processing when the error was raised.
I'd at least expect the internals (here: nunjucks and a-sync-waterfall) to be suppressed.
Maybe with some help of stacktracey and friends?
The unknown path are least helpful.
Yes, I agree a single game changer would be if it just told you the file path instead of saying unknown. I'm sure there's a good reason it doesn't... like the way it loads templates into memory or something before the data merge.
Perhaps @zachleat will enlighten us as to the debug architecture.
I’d love to expand this issue to a request for “meaningful template error messages”.
This seems like a fine place to pass along a tip that has helped me a lot: my build task runs DEBUG=*Error* npx eleventy and the output is far more useful than the default.
Just clarify where are you setting that?
That's the command line used to build. Maybe for your setup the npx isn't necessary, the important part is setting the DEBUG env var.
This is described in the docs but I find *Error* nice because I don't have to hunt through a lot of confirmations to find what went wrong.
(This does not help with figuring out which template is throwing an exception.)
Unknown path should go away in the next version. It will be resolved with the changes to #190.
Are there other concrete steps we can take here?
A simple switch to turn off “info” logging of each output file written would be nice. The spammy output was one of only two things I didn’t enjoy about migrating sites to eleventy. :-)
Alternatively, tracking every template (or layout) that failed, and listing them at the very end of output.
@gerwitz Same. It’s a small price to pay for beginner friendliness though. You can use --quiet to disable this. https://www.11ty.io/docs/usage/#--quiet-if-the-output-is-too-noisy
Can you file the second point as an enhancement request?
Alternatively, tracking every template (or layout) that failed, and listing them at the very end of output.
Most helpful comment
@gerwitz Same. It’s a small price to pay for beginner friendliness though. You can use
--quietto disable this. https://www.11ty.io/docs/usage/#--quiet-if-the-output-is-too-noisyCan you file the second point as an enhancement request?