0

比方說,我有以下任務修改我的合金編譯過程(alloy.jmk構建配置文件)停止合金從構建配置任務建立(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!"); 
}); 

我怎樣才能停止建設抓住條款?當然,我可以刪除try-catch,但然後我的自定義錯誤處理將不會執行...

回答

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!"); 
});