At 20:25 10/02/2002 +1100, Peter Donald wrote:
Error handling in ant sucks ...

I agree 100% - I have a build system running in Ant that builds several dozen executables from Delphi source and have had to do some "funky stuff" in order to ensure the Builds run smoothly.


[ FWIW, doing these builds in one hit gives us *significant* performance improvements. Doing a separate build for each application would take 5-6 minutes per application instead of 7-9 minutes for over 50 apps]

I've some suggestions to toss into the discussion.

I believe that having a single construct that handles both "catch" and "finally" gives some ambiguity about when tasks would be executed. To use Peters Example to explain:

<tbody>
  <try>
    <echo message="About to fail"/>
    <fail message="Failing!"/>
  </try>
  <catch>
    <echo message="the task failed but we are ignoring it"/>
  </catch>
  <finally>
    <echo message="Cleaning up after myself ..."/>
  </finally>
</tbody>

When does the finally task get executed - before the catch or after?

ie Are the tasks executed as:

<echo message="About to fail"/>
<fail message="Failing!"/>
<echo message="the task failed but we are ignoring it"/>
<echo message="Cleaning up after myself ..."/>

or

<echo message="About to fail"/>
<fail message="Failing!"/>
<echo message="Cleaning up after myself ..."/>
<echo message="the task failed but we are ignoring it"/>

There are good arguments both ways - in some cases we want to clean up *before* handing the catch, sometimes *after*.

So, I'd suggest separating the two concepts into two separate tags, one for the "finally" case and one for the "catch" case. This is actually how most languages handle this - Java and Delphi included.

For the first, how about this:

<try>
  <echo message="About to make a mess"/>
  ...
  <finally>
    <echo message="Cleaning up mess"/>
    ....
  </finally>
</try>

For the second case, and keeping in mind that the Ant term is "fail":

<try>
  <echo message="About to fail"/>
  ...
  <onFail>
    <echo message="It failed."/>
  </onFail>
</try>


This avoids any problems with possible ambiguity. Peters original example could be restated as this:


<try>
  <try>
    <echo message="About to fail"/>
    <fail message="Failing!"/>
    <onFail>
      <echo message="the task failed but we are ignoring it"/>
    </onFail>
  </try>
  <finally>
    <echo message="Cleaning up after myself ..."/>
  </finally>
</try>

Just my 2c - what do you think?

Cheers,
Bevan.


-- "Programming is an Art Form that Fights Back"

Bevan Arps (<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED])
Senior OO Analyst, ACT Financial Systems

This communication is confidential to ACT Financial Systems (Asia Pacific) and is intended for use only by the addressee. The views and opinions expressed in this email are the senders own and do not represent the views and opinions of ACT Financial Systems (Asia Pacific).



Reply via email to