0

Let's say I have the following task modifying my Alloy compile process (alloy.jmk build configuration file)

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

How can I stop the build in the catch-clause? Of course I could just remove the try-catch but then my custom error handling won't be executed...

stiemannkj1
  • 4,418
  • 3
  • 25
  • 45
simne7
  • 194
  • 1
  • 1
  • 12

1 Answers1

0

Well, answering my own question here... It seems it was too easy ... Simply throw a custom error inside the catch-statement like so

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!");
});
simne7
  • 194
  • 1
  • 1
  • 12