Skip to content

Instantly share code, notes, and snippets.

@luigimannoni
Created October 29, 2015 14:34
Show Gist options
  • Select an option

  • Save luigimannoni/5372222158be15ad67d4 to your computer and use it in GitHub Desktop.

Select an option

Save luigimannoni/5372222158be15ad67d4 to your computer and use it in GitHub Desktop.
Gulp nice error Handler
// Gulp
var gulp = require('gulp');
// Gulp plug-ins
var plumber = require('gulp-plumber'), // Error pipe streaming
util = require('gulp-util'), // Extends gulp utilities
notify = require('gulp-notify'); // Toast notifications for MacOS and Windows
// Error reporting function.
var reportError = function (error) {
// Log into console and beep.
util.log(util.colors.red('Error'), error.message);
util.beep();
// Toast message
notify({
title: 'Task Failed [' + error.plugin + ']',
message: error.message,
}).write(error);
// Prevent the 'watch' task from stopping
this.emit('end');
};
/**
* USAGE:
*
* gulp.src(['./src/js/application/**/**.js'])
* .pipe(plumber({ errorHandler: reportError }))
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment