I'm having difficulty catching errors in nant using "onfailure".
Onfailure gets called on an error (good), but the actual error doesn't
seem to be available until *after* onfailure has already run. 

For example: 

<?xml version="1.0"?>
<project name="OnFailureTest" default="foo">  

        <property name="nant.onsuccess" value="onsuccess"/>
        <property name="nant.onfailure" value="onfailure"/>

        <target name="foo" >
                <fail message="=======>Here is the failure message!"/>
        </target>

        
        <target name="onfailure">
                <echo message="hello from onfailure . . . I want to
report the error but I don't know what it is ! !"/>

                <!--  I'd like to email the build error, but I don't
know what it was yet ! . . . -->
                
                <mail subject="Build failed." format="Html" from="build"
tolist="[EMAIL PROTECTED]" mailhost="mailServer"
                        message="and the build error is . . . ?">
                        <files>
                                <include
name="c:\stuffIWantToEmail.html" />
                        </files>
                </mail>         
        </target>

        <target name="onsuccess">
                <echo message="Build successful . . . "/>
        </target>
</project> 


To get around this, I stopped using onsuccess and onfailure altogether,
and switched to the MailLogger.  
This works much better, but "<mail>" does a couple things that
MailLogger doesn't:
        1) I want to be able to specify MailLogger.body.format = html
        2) I want to be able to include a fileset in the body of the
email, the way "<mail>" takes "<files>".
For example:

<?xml version="1.0"?>
<project name="MailLoggerTest" default="foo">  

        <property name="MailLogger.mailhost" value="mailServer" />
        <property name="MailLogger.from" value="[EMAIL PROTECTED]" />
        <property name="MailLogger.body.format" value="html" />
<!-- <mail> has this, MailLogger doesn't -->

        <property name="MailLogger.failure.to" value="[EMAIL PROTECTED]"/>
        <property name="MailLogger.failure.subject" value="Build
Failure" />

        <property name="MailLogger.success.to" value="[EMAIL PROTECTED]"/>
        <property name="MailLogger.success.subject" value="Build
Success" />
        
        <!-- Mail logger works perfectly: I'll get the error in the body
of the email.  Great!!
        But now I'd like to include some more info with the email using
<files>, like I can in the mail task.  
        I need this: -->
        <property name="MailLogger.success.files" value="files"/>

        <fileset id="files">    
                <include name="c:\stuffIWantToEmail.html" />
        </fileset>
        
</project>

Changing Log.cs to allow for including a fileset and html formatting
with MailLogger isn't a big deal (I can post a diff), 
but am I missing something with the way nant handles errors ?

Thanks,
Jeff


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
nant-developers mailing list
nant-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to