假设我有以下任务来修改我的合金编译过程(alloy.jmk构建配置文件)
task("pre:compile", function (e, log) {
// execute something that may throw an error
try {
// ...
}
catch(err) {
// do some custom error handling
// ...
// !!! need to stop the build here !!!
}
log.info("My task completed!");
});如何在catch-子句中停止构建?当然,我可以只删除try-catch,但这样我的自定义错误处理就不会执行了……
发布于 2017-06-08 19:19:32
好吧,在这里回答我自己的问题...看起来太简单了..。只需在catch语句中抛出一个自定义错误,如下所示
task("pre:compile", function (e, log) {
// execute something that may throw an error
try {
// ...
}
catch(err) {
// do some custom error handling
// ...
throw('throwing some error to stop the build');
}
log.info("My task completed!");
});https://stackoverflow.com/questions/44434275
复制相似问题