问题描述
我正在创建一个在某些情况下可能会失败的 gulp 任务.
当通过 gulp 运行我的任务并遇到错误时,该错误将呈现得相当难看.我想以一种方式呈现错误,例如,jslint gulp-util 的 PluginError
.
它实际上只是在其中创建一个 PluginError
并抛出它,但这似乎不太正确.另一个不太好的解决方案是设置
至少有更好的错误输出.gulp.task.Error
会很好.
据我所知,从 gulp 中抛出错误并不是很好.但是我发现了这个我曾经为我工作的博客条目.
http://gotofritz.net/博客/geekery/how-to-generate-error-in-gulp-task/
编辑:gulp-util
已弃用.相反,请使用 plugin-error
包.p>
我的例子:
I am creating a gulp task which might fail under certain circumstances.
When running my task via gulp and running into the error, the error will be presented rather ugly.
I would like to present the error in a way as it is done by e.g. jslint gulp-util's PluginError
.
It actually works to just create a PluginError
there and throw it but that doesn't seem quite right.
Another solution not that nice would be to set
for at least a little nicer error output. A gulp.task.Error
would be nice.
From what I've seen its not great to throw an error from gulp. But I found this blog entry that I used to work for me.
http://gotofritz.net/blog/geekery/how-to-generate-error-in-gulp-task/
Edit: gulp-util
has been deprecated. Instead, use the plugin-error
package.
My Example:
这篇关于在 gulp 任务中很好地抛出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!