11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.

Home Page:https://www.11ty.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve Serverless Error Messaging

zachleat opened this issue · comments

Not quite good enough, here!

https://contrast-11ties.netlify.app/contrast/?foreground=%23ffffff&background=NOVALUE

{
  "error": "Couldn’t find any generated output from Eleventy (URL path parameters: {})."
}

via https://twitter.com/m_andrasch/status/1459074004707426308

For future me: we should solve this in a better way upstream in the toJSON (and related) calls to show error information?

Things to think about:

  • toJSON returns an array at the top level. I wish it used { results: [] } instead which would allow for { error: {} }—we may need a better way around this.
  • We may need to be careful about being too open about error messaging in serverless mode, which may have implications if we console.log the full error stack to the end user.

Hi, is there any workaround to send custom errors from rendering to final user ?

Currently, I raise an error from some filters/globals with custom message and statusCode field, but it is caught and replaced by "Having trouble rendering njk template ..." before reaching the .catch which follows elev.getOutput() and thus my users ever see a 500 without details.

Stale per #3074.