[Yanel-dev] exception handling in Ant tasks
Michael Wechner
michael.wechner at wyona.com
Sat Apr 10 07:50:21 CEST 2010
Guillaume Déflache wrote:
> 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!!!
I understand your frustration, but you need to be more specific by
providing a patch of the MergeResourceTypesConfigsTask class
re which errors you want to throw and give specific examples when these
errors are thrown, e.g. resource-types.xml is not well-formed.
The case that your resource-types.xml is not found is NOT a build error,
because a realm does not have to have such a file.
That's rather a matter of documentation. Also you could enhance this
documentation, e.g.
http://www.yanel.org/en/documentation/configuration/resource-types_xml.html
http://www.yanel.org/en/documentation/create-new-resource.html
Thanks
Michi
More information about the Yanel-development
mailing list