jgable / gulp-cache

A cache proxy task for Gulp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to handle error?

steverandy opened this issue · comments

I'm using this plugin with gulp-coffee and gulp.watch to do incremental build.
When there is an error thrown by coffee plugin, it seems to crash gulp.watch.
I tried to use gulp-plumber but didn't help.
What's the correct way of handling error?

stream = gulp.src bundles[filename]
  .pipe plumber()
  .pipe coffeeFilter
  .pipe cache coffee()
  .pipe coffeeFilter.restore()
  .pipe concat filename

Can you put together an example of it crashing in a test repo that I can clone down and debug? Otherwise, I'll just waste a bunch of time setting up something wrong that doesn't match your environment.

I got it fixed by emitting "end" event after the error event.

stream = gulp.src bundles[filename]
  .pipe coffeeFilter
  .pipe cache coffee()
  .on "error", (err) ->
    console.log err.toString()
    @emit "end"
  .pipe coffeeFilter.restore()
  .pipe concat filename