[Yanel-dev] exception handling in Ant tasks
Guillaume Déflache
guillaume.deflache at wyona.com
Fri Apr 9 19:38:48 CEST 2010
Could we stop logging exceptions in Ant tasks and simply rethrow them as
build exceptions (org.apache.tools.ant.BuildException).
The Ant tasks's "execute" entry-point method that every task shall
implement already throws this type of exception so by only (re)throwing
it here and in other methods:
- the stacktraces are simpler because they don't get displayed and/or
wrapped many times
- one does not litter one's code with a lot of exception handling, the
only needed code is "throws BuildException" appended on all methods
signatures, or even "throws Exception" with only a exception wrapper
from Exception to BuildException on the "execute" method
- errors ultimately get catched by Ant anyway, which already does a
great job at showing full stacktraces, *and failing the whole build*
I am asking because I spent quite some time wondering why my
resource-type was not found, it was only because my project's
resource-types.xml was not well-formed and it just got ignored because
of these issues (culprit here being Yanel's
src/build/java/org/wyona/yanel/ant/MergeResourceTypesConfigsTask.java)...
Better fail fast than silently!!!
More information about the Yanel-development
mailing list