Implement a better error handler
See original GitHub issueI wanted to make a gulp watch task, but every time it stopped when an error were found.
Since I’ve searched but found no real workaround, the only solution I found was to handle the error like gulp-sass
does. It does not interrupt the watch and just report it on the console.
Solution source: https://github.com/dlmanning/gulp-sass/blob/master/index.js#L178
An easy implementation for whoever has problem with it is:
const babel = require('gulp-babel');
babel.logError = function logError(error) {
gutil.log(error.toString(), '\n\b', error.codeFrame);
this.emit('end');
};
// how to use
babel({...})
.on('error', babel.logError)
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to implement complete error handling? - Codegrip
Error handling is when your software is capable to counter or confiscate errors that may have been brought on by a programmer mistake...
Read more >Better Error Handling In NodeJS With Error Classes
This article is for JavaScript and NodeJS developers who want to improve error-handling in their applications.
Read more >Best Practices for Node.js Error-handling - Toptal
This article will introduce you to error-handling in Node.js and demonstrate ... Using Node.js built-in Error object is a good practice because it...
Read more >koa-better-error-handler - npm
A better error-handler for Lad and Koa. Makes `ctx.throw` awesome (best used with koa-404-handler). Latest version: 10.0.7, last published: ...
Read more >Error handling - Lisperator.net
The exception system we implement here will fall short in the face of parallelism. Proper support for the parallel copyTree needs some more...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is in fact what I’m proposing, a nifty addition that does not change in any way the current implementation. It just simplifies and reduce code for the developer who just need to log errors while on watch.
@tomsotte I guess giving the user, chance to work around error event is better than just logging and not throwing an error.
User may need to do something when error event is fired. I am also doing it the same way you are while working with watchers.