Open tremby opened 8 years ago
There was no error actually being thrown. Maybe something changed upstream: it looks like you now need to pass rethrow: true
as part of twigOpts
. Adding this in gulp-twig/index.js around line 36 leads to the error being properly thrown and caught.
Still wondering what the best way is to display a shorter error message. It looks like the twig package is outputting it all no matter what settings are passed.
Hmm, i'd have to dive into that a bit. Perhaps your own errorhandler that gets the full error so you can pick whatever you want to log or put into the stream.
The thing is, upstream twig doesn't throw you the error at all unless you pass that rethrow
option. It has its own catch block, catches its own error and produces that big stack trace.
And even if you do pass rethrow: true
, it still outputs the error to stdout before throwing it again. Messy.
Experiencing the same thing as @tremby.
Can you provide an example of rolling my own error handler?
@tremby what's your feeling about this these days? I've had good luck with gulp-plumber but it's been a while since I looked into this end of things
I haven't used gulp-twig in quite some time, but this was always something which annoyed me, and maybe I'll have to come back to one of those projects which uses this at some point. So I guess my feeling about this is that a solution should be found. Looks like others are interested in a fix too.
In my gulp task to compile twig templates, if there's an error (such as in
{% include 'file-which-doesnt-exist.twig' %}
) I get a huge stack trace.What's the recommended way to set up my gulpfile so I have just a short message on errors?
Setting
onError
to something to echo a short message doesn't seem to do anything (it doesn't seem to run) and settingerrorEchoToConsole
to true doesn't seem to do anything either.I also tried adding
.on('error', gutil.log)
to the stream, but this doesn't have any effect.