Table of Contents

Class JobExecutionException

Namespace
Quartz
Assembly
Quartz.dll

An exception that can be thrown by a IJob to indicate to the Quartz IScheduler that an error occurred while executing, and whether or not the IJob requests to be re-fired immediately (using the same IJobExecutionContext), or whether it wants to be unscheduled.

public sealed class JobExecutionException : SchedulerException, ISerializable
Inheritance
JobExecutionException
Implements
Inherited Members

Remarks

The instructions to the scheduler are init-only properties, set with an object initializer:

throw new JobExecutionException(ex) { RefireImmediately = true };

Note that if the flag for 'refire immediately' is set, the flags for unscheduling the Job are ignored.

The type is sealed, and deliberately: what it says is three instructions to the scheduler, and the scheduler reads exactly those three. A subclass adding a fourth would be a directive nothing acts on, and a framework that subclassed it did so to carry its own state past the scheduler to its own listener. Data is the supported carrier for that. An instance a job throws is handed to JobWasExecuted(IJobExecutionContext, JobExecutionException?, CancellationToken) unchanged — the run shell only fills in JobDetail — so whatever is in Data is there when the listener reads it:

throw new JobExecutionException("import failed", ex) { Data = { ["tenant"] = tenantId } };

Wrapping an exception of your own as the cause carries typed state just as well: throw new JobExecutionException(new ImportFailed(tenantId));, read back with jobException.InnerException is ImportFailed failure. An exception that is not a JobExecutionException reaches the listener two hops down instead, wrapped as JobExecutionExceptionJobExecutionProcessException → your exception, so a listener that wants either shape unwraps until it finds what it knows.

Constructors

JobExecutionException()

Create a JobExecutionException.

public JobExecutionException()

JobExecutionException(Exception)

Create a JobExecutionException, with the given cause.

public JobExecutionException(Exception innerException)

Parameters

innerException Exception

The cause.

JobExecutionException(string)

Create a JobExecutionException, with the given message.

public JobExecutionException(string message)

Parameters

message string

JobExecutionException(string, Exception)

Initializes a new instance of the JobExecutionException class.

public JobExecutionException(string message, Exception innerException)

Parameters

message string

The message.

innerException Exception

The original cause.

Properties

JobDetail

Gets the IJobDetail of the job that was being executed when the exception was thrown. This is set automatically by the scheduler.

public IJobDetail? JobDetail { get; }

Property Value

IJobDetail

RefireImmediately

Whether the job should be re-fired immediately with the same IJobExecutionContext.

public bool RefireImmediately { get; init; }

Property Value

bool

UnscheduleAllTriggers

Whether all triggers of the job should be unscheduled.

public bool UnscheduleAllTriggers { get; init; }

Property Value

bool

UnscheduleFiringTrigger

Whether the firing trigger should be unscheduled.

public bool UnscheduleFiringTrigger { get; init; }

Property Value

bool

Methods

ToString()

Creates and returns a string representation of the current exception.

public override string ToString()

Returns

string

A string representation of the current exception.

See Also