C# 使用IJobListener(Quartz.NET)获取作业异常
我正在使用Quartz.NET中的IJobListener来审核所有工作的成功/失败。当作业失败时,我希望将异常放入IJobListener中,以便也可以存储异常以供以后分析 当前我的工作侦听器如下所示:C# 使用IJobListener(Quartz.NET)获取作业异常,c#,quartz-scheduler,quartz.net,C#,Quartz Scheduler,Quartz.net,我正在使用Quartz.NET中的IJobListener来审核所有工作的成功/失败。当作业失败时,我希望将异常放入IJobListener中,以便也可以存储异常以供以后分析 当前我的工作侦听器如下所示: public virtual void JobWasExecuted(JobExecutionContext context, JobExecutionException x) { } 但是,即使作业的Execute方法中的所有事务都封装在一个带有catch(异常x)的tr
public virtual void JobWasExecuted(JobExecutionContext context, JobExecutionException x)
{
}
但是,即使作业的Execute方法中的所有事务都封装在一个带有catch(异常x)的try中,然后我抛出该catch,但JobExecutionException的“x”永远不会填充
是否有一种特殊的方法可以实际将异常获取给作业侦听器
谢谢您只是抛出异常吗?您是否尝试过使用JobWasExecuted期望的正确类型包装它
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
}
}
你只是抛出异常吗?您是否尝试过使用JobWasExecuted期望的正确类型包装它
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
}
}