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

capturing errors from templates #2

Open
atheros opened this issue Feb 22, 2013 · 0 comments
Open

capturing errors from templates #2

atheros opened this issue Feb 22, 2013 · 0 comments

Comments

@atheros
Copy link

atheros commented Feb 22, 2013

I use the code:

var stream = nsmarty.assign(template, data);
util.pump(stream, req.res);

Since nsmarty uses asynchronous calls, it is impossible to capture any kinds of errors. Everything nsmarty (or the libraries it uses) throws lands in uncaughtExeption event handler on the process.

The sideeffect is that in case of a template error (unclosed block, syntax error, whatever), the connection from the browser is pending forever (until the socket timesout) and it is impossible to send an error message.

A very helpfull thing would be to add method accepting a standard callback, like:

nsmarty.fetch(mytemplate, data, function (err, result) {
   if (err) {
      res.end(someErrorPage());
   } else {
      res.end(result);
   }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant