floatdrop / gulp-plumber

Fixing Node pipes
MIT License
806 stars 32 forks source link

Expose error handler #35

Open holic opened 9 years ago

holic commented 9 years ago

It would be great if we could use the same error handler when some plugins require explicitly handling errors (e.g. browserify).

gulp.task('example', function () {
    return browserify({ debug: true })
        .bundle()
        .on('error', plumber.handleError)
        .pipe(plumber())
        .pipe(source('example.js'))
        .pipe(buffer())
        .pipe(gulp.dest('dist/js'))
})
floatdrop commented 9 years ago

You can do this:

function handleError(err) {
    // ...
}

gulp.task('example', function () {
    return browserify({ debug: true })
        .bundle()
        .on('error', handleError)
        .pipe(plumber(handleError))
        .pipe(source('example.js'))
        .pipe(buffer())
        .pipe(gulp.dest('dist/js'))
})