views:

36

answers:

1

Hi, I'm using an IJobListener in Quartz.NET to audit all job successes/failures. When a job fails, I want the exception to be taken into the IJobListener so the exception can be stored too for later analysis.

Currently my job listener is like this:

public virtual void JobWasExecuted(JobExecutionContext context, JobExecutionException x)
        {

}

But even though all transactions in the Execute method for the job are encased in a try with a catch(Exception x), which I then throw, the 'x' for JobExecutionException is never populated.

Is there a special way of actually getting the exception to the job listener?

Thanks

+1  A: 

Do you just throw the Exception? Have you tried wrapping it in the right Type that JobWasExecuted is expecting?

public virtual void Execute(JobExecutionContext context)
{
    try 
    {
      //divide by zero... or something else that causes an exception
    }
    catch (Exception e)
    {
      JobExecutionException je = new JobExecutionException(e);
      je.RefireImmediately = true;  //do something with the exception
      throw je;  //throw JobExecutionException
    }
}
Paul U