让我说我有以下任务修改我的Alloy编译过程(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但是我的自定义错误处理不会被执行......
答案 0 :(得分:0)
好吧,在这里回答我自己的问题......看起来太简单了......只需在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!");
});