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

Error handler being ignored #59

Open
eranimo opened this issue Apr 9, 2015 · 3 comments
Open

Error handler being ignored #59

eranimo opened this issue Apr 9, 2015 · 3 comments

Comments

@eranimo
Copy link

eranimo commented Apr 9, 2015

coffeeStream = coffee().on('error', (error) ->
    {filename} = error
    extension = path.extname(error.filename)
    dirname = path.dirname(filename)
    basename = path.basename(error.filename, '.coffee')
    target = path.join(dirname, "#{basename}.js")
)

gulp.task("coffee", () ->
    return gulp.src(dedupeGlobs(paths.coffee))
        .pipe(sourcemaps.init())
        .pipe(ngClassify(ngClassifyOptions))
        .pipe(coffeeStream)
        .pipe(ngAnnotate())
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(COMPILE_PATH))

I have a syntax error in one of the files being loaded into the task.

The following prints to the console:

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: [stdin]:1:1: error: unexpected &
&*^%$^#&*()_

I've tried adding gulp-plumber, but all it did was prevent gulp from exiting.

@yocontra
Copy link
Member

yocontra commented Apr 9, 2015

This doesn't work?

handler = (error) ->
    {filename} = error
    extension = path.extname(error.filename)
    dirname = path.dirname(filename)
    basename = path.basename(error.filename, '.coffee')
    target = path.join(dirname, "#{basename}.js")

gulp.task "coffee", ->
    return gulp.src(dedupeGlobs(paths.coffee))
        .pipe(sourcemaps.init())
        .pipe(ngClassify(ngClassifyOptions))
        .pipe(coffeeStream).on('error', handler)
        .pipe(ngAnnotate())
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(COMPILE_PATH))

@eranimo
Copy link
Author

eranimo commented Apr 10, 2015

No it does not. Plumber still catches the unhandled error, but I can't do anything useful with it because its not an error object.

@manuel-di-iorio
Copy link

The only way to correctly catch the error with gulp-coffee is using Plumber. Without it, the error is caught only the first time and then the task will stop watching (I mean with gulp.watch)

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

3 participants