Take the following Gulp error message, for example:
Example Problem – Useless Error Message
Pretty useless. The only thing one can discern from the error is that it has something to do with the less parser. But what? Who the #$@% knows.
But what if you could get the following instead?
Example Solution: Improved Error Message
This error message is much improved. It tells us exactly which less file is failing the parser. It also tells us the precise failing line number, and it even gives us an extract of the CSS around that line number. Without even opening the file, we can see the erroneous colon after the CSS class,
The answer to this problem lies in the gulp-util plugin.
Install the plugin and also add it to your package.json file with the following command:
npm install --save-dev gulp-util
Next, add the following declaration to the top of your gulp.js file:
var gutil = require('gulp-util');
Finally, attach the following error handler to tasks (when you are compiling less, uglifying some code, or whatever):
With this little gem, you can now spend less time troubleshooting errors and more time creating works of art.