shannonmoeller / gulp-hb

A sane Gulp plugin to compile Handlebars templates. Useful as a static site generator.

Home Page:http://npm.im/gulp-hb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Attach file object on error object

heinzmuller opened this issue · comments

I don't know if this is the correct way of doing this, but I've done some testing locally and this seems to work totally fine.

catch (err) {
    // Attach file to error object
    err.file = file;
    cb(new gutil.PluginError('gulp-hb', err, {
        stack: err.stack,
        showStack: true
    }));
}

This allows you to grab the failed file when handling errors

...
.pipe(plumber({errorHandler: notify.onError("<%= error.file.relative %>: <%= error.message %>")}))
.pipe(hb())
...
[14:22:57] gulp-notify: [Error running Gulp] search.hbs: Parse error on line 5:

I have a v3 release candidate ready that should address this issue. Are you available to kick the tires?

npm i --save "shannonmoeller/gulp-hb#v3"

Released as v3.0.0.

Sorry for the late reply, thanks for the addition!

I'll give 3.0 a go :)