Skip to content

Instantly share code, notes, and snippets.

@nahuelsotelo
Last active April 20, 2016 09:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nahuelsotelo/758849ffbdb553cb49c1 to your computer and use it in GitHub Desktop.
Save nahuelsotelo/758849ffbdb553cb49c1 to your computer and use it in GitHub Desktop.
ERROR HANDLER
var beep = require('beepbeep');
var colors = require('colors');
var onError = function(err) {
beep([200, 200]);
var formatOutput = function(context) {
var msg, file, line, description;
if(context == 'gulp-babel') {
file = String(err.fileName);
line = String(err.loc.line);
description = String(err.name + err.message.replace(err.fileName, ''));
} else if(err.plugin == 'gulp-sass') {
file = String(err.relativePath);
line = String(err.line);
description = String(err.messageOriginal);
} else {
file = '';
line = '';
description = err;
}
msg =
'file: '.bold.white + file.bold.green + '\n' +
'line: '.bold.white + line.bold.green + '\n\n' +
description.bold.red + '\n';
return msg
}
var errorMsg = formatOutput(err.plugin);
console.log(
'\n\n******************************************\n'.bold.gray +
' ***********'.bold.gray +
' \(╯°□°)╯'.bold.magenta + ' ︵ '.bold.blue + 'ɹoɹɹǝ '.bold.red +
'***********'.bold.gray +
'\n******************************************\n\n'.bold.gray +
errorMsg +
'\n******************************************\n\n'.bold.gray);
this.emit('end');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment