首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从构建配置任务(alloy.jmk)停止合金构建

从构建配置任务(alloy.jmk)停止合金构建
EN

Stack Overflow用户
提问于 2017-06-08 19:19:32
回答 1查看 47关注 0票数 0

假设我有以下任务来修改我的合金编译过程(alloy.jmk构建配置文件)

代码语言:javascript
复制
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,但这样我的自定义错误处理就不会执行了……

EN

回答 1

Stack Overflow用户

发布于 2017-06-08 19:19:32

好吧,在这里回答我自己的问题...看起来太简单了..。只需在catch语句中抛出一个自定义错误,如下所示

代码语言:javascript
复制
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!");
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44434275

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档