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

uncaughtException if partial is missing #165

Closed
JeffML opened this issue Jun 4, 2019 · 2 comments
Closed

uncaughtException if partial is missing #165

JeffML opened this issue Jun 4, 2019 · 2 comments

Comments

@JeffML
Copy link

JeffML commented Jun 4, 2019

I've registered a helper that throws an exception if a partial is not found, but that error is not propagated up to NodeJS render() method that is trying to render the file that has the template:

stack": [
    "Error: no partial found",
    "    at Object.hbs.registerHelper (/Users/jeff.l/Documents/workspace/responsive-web-design/RWD/rwd-modules/hbs-helpers.js:560:11)",
    "    at Object.eval (eval at createFunctionContext (/Users/jeff.l/Documents/workspace/responsive-web-design/RWD/node_modules/handlebars/lib/handlebars/compiler/javascript-compiler.js:239:23), <anonymous>:11:110)",
    "    at main (/Users/jeff.l/Documents/workspace/responsive-web-design/RWD/node_modules/handlebars/lib/handlebars/runtime.js:152:32)",
    "    at ret (/Users/jeff.l/Documents/workspace/responsive-web-design/RWD/node_modules/handlebars/lib/handlebars/runtime.js:155:12)",
    "    at ret (/Users/jeff.l/Documents/workspace/responsive-web-design/RWD/node_modules/handlebars/lib/handlebars/compiler/compiler.js:513:21)",
    "    at render_file (/Users/jeff.l/Documents/workspace/responsive-web-design/RWD/node_modules/hbs/lib/hbs.js:49:23)",
    "    at ReadFileContext.callback (/Users/jeff.l/Documents/workspace/responsive-web-design/RWD/node_modules/hbs/lib/hbs.js:168:16)",
    "    at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:242:13)"
  ],
  "level": "error",
  "message": "uncaughtException: no partial found"

That last message come from my handlebars helper function, which throws an Error. It would be useful to catch this error higher up the chain so that I can try alternate rendering in the node server.

@dougwilson
Copy link
Contributor

Thanks for the report! Could you put together a reproduction that shows the error for example? So i can run and debug it.

Partial rendering is an async task, as as long as whatever that NodeJS rendering API is async and not sync it should be possible to do (but you'd need to provide a callback and cannot use try catch).

But having a demonstration would help understand the issue better.

@dougwilson
Copy link
Contributor

With no further information provided, I will assume that PR #156 will fix your issue.

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

No branches or pull requests

2 participants