ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 24877] - exec task doesn't handle error conditions well
Date Mon, 24 Nov 2003 18:21:39 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24877>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24877

exec task doesn't handle error conditions well





------- Additional Comments From eric@timebytes.com  2003-11-24 18:21 -------
You could say the same thing about the resultproperty, which *is* displayed 
when the failonerror is enabled (despite the user's setting or non-setting of 
this property).  That's why the manual says "Only of interest if 
failonerror=false." If we did the same thing with errorproperty, we could add 
the same line to the manual by errorproperty as well.

The bottom line is that I need some reasonable way to display the error message 
when the execed subprogram fails!  I have yet to hear any way to do this, short 
of having a dedicated property and a dedicated target for *each* call to exec:


<exec executable="perl" failonerror="no" errorproperty="eP1" 
resultproperty="rP1">
  <arg line="Prog1.pl" />
</exec>

<condition property="execFailed1">
  <not>
    <equals arg1="${rp1}" arg2="0" />
  </not>
</condition>

<antcall target="failOnError1" />

<target name="failOnError1" if="execFailed1">
  <fail message="Error: an executed program has returned the following 
error: '${eP1}'.  Please contact your site
 administrator for further help." />
</target> <!-- failOnError1 -->


<exec executable="perl" failonerror="no" errorproperty="eP2" 
resultproperty="rP2">
  <arg line="Prog2.pl" />
</exec>

<condition property="execFailed2">
  <not>
    <equals arg1="${rp2}" arg2="0" />
  </not>
</condition>

<antcall target="failOnError2" />

<target name="failOnError2" if="execFailed2">
  <fail message="Error: an executed program has returned the following 
error: '${eP2}'.  Please contact your site administrator for further help." />
</target> <!-- failOnError2 -->

repeated again and again.  That's 12 lines of noise to 3 lines of useful code.

And talk about subtle bugs - what do you think will happen if the programmer 
screws up his cut-and-paste and leaves a '3' when he needed a '4?'  Good luck 
catching that in the testing process!!!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message