title: Handling Gulp.js vinyl stream errors properly when errors are thrown from streaming libs
body: <p>I am transpiling React JSX using Gulp (yeah I know).</p>
  
  <p>I have this Gulp task:</p>
  
  <pre><code>gulp.task('transpile-jsx', function () {
      return transpileJSX().on('error',function(err){   // &lt; I just added this error handler, but it doesn't do much
          console.error(err);
      });
  });
  </code></pre>
  
  <p>the above task is called like so:</p>
  
  <pre><code>gulp.task('metagen:all', ['transpile-jsx'], function (done) {
  
      runAllMetagens(done);
  
  });
  </code></pre>
  
  <p>and the actual function that does the work looks like:</p>
  
  <pre><code>function transpileJSX() {
      return gulp.src('./public/static/app/js/views/**/*.js').pipe(react({harmony: true}))
          .pipe(gulp.dest('./public/static/app/js/jsx'));
  }
  </code></pre>
  
  <p>a try/catch won't work for streams because they are asynchronous, so what is the best way to attach an error handler so that my gulp process doesn't tank when it hits JSX transpilation error like so:</p>
  
  <pre><code>events.js:141
        throw er; // Unhandled 'error' event
        ^
  Error: Parse Error: Line 94: Unexpected token &gt;
      at throwError (/Users/amills001c/WebstormProjects/baymax/AdminUI/node_modules/gulp-react/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:2808:21)
      at throwUnexpected (/Users/amills001c/WebstormProjects/baymax/AdminUI/node_modules/gulp-react/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:2870:9)
      at parseJSXChild (/Users/amills001c/WebstormProjects/baymax/AdminUI/node_modules/gulp-react/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:7068:13)
      at parseJSXElement (/Users/amills001c/WebstormProjects/baymax/AdminUI/node_modules/gulp-react/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:7140:31)
      at parsePrimaryExpression (/Users/amills001c/WebstormProjects/baymax/AdminUI/node_modules/gulp-react/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:3572:20)
      at parseLeftHandSideExpressionAllowCall (/Users/amills001c/WebstormProjects/baymax/AdminUI/node_modules/gulp-react/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:3656:61)
      at parsePostfixExpression (/Users/amills001c/WebstormProjects/baymax/AdminUI/node_modules/gulp-react/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:3696:20)
      at parseUnaryExpression (/Users/amills001c/WebstormProjects/baymax/AdminUI/node_modules/gulp-react/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:3763:16)
      at parseBinaryExpression (/Users/amills001c/WebstormProjects/baymax/AdminUI/node_modules/gulp-react/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:3853:16)
      at parseConditionalExpression (/Users/amills001c/WebstormProjects/baymax/AdminUI/node_modules/gulp-react/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:3913:16)
  </code></pre>
  
  <p>The problem I am having is that transpilation errors that happen in real-time are crashing my dev server, (because my dev server is my gulp process), and these transpilation errors are crashing my gulp process.</p>