clay / handlebars

A collection of helpers and partials for handlebars
MIT License
15 stars 8 forks source link

add try/catch to read helper #83

Closed KerenLerner closed 1 year ago

KerenLerner commented 1 year ago

Handle read exceptions more gracefully. Without this change, when a template tries to read a file that doesn't exist (e.g. an svg file), the entire page will fail to render, instead displaying this error message in the browser:

{
*       errno: -2,
*       syscall: "open",
*       code: "ENOENT",
*       path: "whatever/doesntexist.svg"
}

With this change, the page simply loads without the asset that doesn't exist and logs an error to the console.

KerenLerner commented 1 year ago

I think this is fine to fix the issue we're having, but I'd like to dig more into why / where this issue is happening.

Thanks for taking a look James. It was happening whenever we try to read a file that doesn't exist (say, a typo in the path to an SVG).