title: Gulp: Error Messages and Notifications with Plumber
body: <p><a href="https://stackoverflow.com/questions/25782341/global-error-message-using-gulp-notify-plumber">In this example</a>, it states you can use Gulp-Plumber and Gulp-Notify to display a message and sound each time there is an error. Gulp-Plumber will ensure that Gulp watch will continue to run.</p>
  
  <p>However, when I try it, I keep on getting this error message, which causes Gulp to stop:</p>
  
  <pre><code>events.js:72
          throw er; // Unhandled 'error' event
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>var gulp            = require('gulp'),
      sass            = require('gulp-ruby-sass'),
      jshint          = require('gulp-jshint'),
      uglify          = require('gulp-uglify'),
      rename          = require('gulp-rename'),
      concat          = require('gulp-concat'),
      notify          = require('gulp-notify'),
      plumber         = require('gulp-plumber'),
  
  
  
    var onError = function(err) {
          notify.onError({
                      title:    "Gulp",
                      subtitle: "Failure!",
                      message:  "Error: &lt;%= error.message %&gt;",
                      sound:    "Beep"
                  })(err);
  
          this.emit('end');
           };
  
  
  //Scripts Task
  gulp.task('scripts', function() {
      gulp.src('frontend/build/js/*.js')
      .pipe(jshint('.jshintrc'))
      .pipe(jshint.reporter('default'))
      .pipe(concat('main.js'))
      .pipe(gulp.dest('frontend/dist/js'))
      .pipe(rename({suffix: '.min'}))
      .pipe(uglify())
      .pipe(gulp.dest('frontend/dist/scripts'))
         .pipe(notify({ 
             sound: "Frog"
      }));
  });
  
  
  //Styles Task
  gulp.task('styles', function() { 
      return sass('frontend/build/scss/', {style: 'expanded'})
      .pipe(plumber({errorHandler: onError}))
      .pipe(gulp.dest('frontend/dist/css/'))
      .pipe(rename({suffix: '.min'}))
      .pipe(gulp.dest('dist/styles'))
      .pipe(notify({ // Add gulpif here
             sound: "Pop"
     }));
  
  });
  </code></pre>
  
  <p>The only difference between my code and the example is that I have moved onError as a global function so it can be used in both the scripts and styles task. However, even if I move it back inside the styles function, the same error message occurs.</p>
  
  <p>(the code I have posted is abbreviated, the full code can be found <a href="http://jsfiddle.net/big_smile/299gpx3s/" rel="nofollow noreferrer">here</a>)</p>
  
  <p>Also, is there a way to hide the notification message on success so I just get the sound? Thanks!</p>