There are a few different approaches to that.
If you want to do it generically, you can register an event listener:
bpipe.EventManager.instance.addListener(bpipe.PipelineEvent.STAGE_COMPLETED) { type, desc, details ->
if(!details.stage.succeeded)
println "Oh oh, received event of type $type: something failed:\n\n $desc\n\nThe details were:\n\n$details\n"
}
hello = {
exec """
echo "I'm such a failure"
false
"""
}
run {
hello
}
You can also use regular Java / Groovy exception handling if you only care about a particular stage:
hello = {
try {
exec """
echo "I'm also a failure"
false
"""
}
catch(Exception e) {
println "Hmm, I caught a failure!"
throw e
}
}
run {
hello + world
}
This second is a little bit more complex because Bpipe throws exceptions in some routine cases (for example, when you run "bpipe test", etc), so depending on your purpose you might need to avoid those. However it would also let you catch and choose not to rethrow the exception if you want to ignore the error and leave the pipeline running.
Cheers,
Simon