Skip to content

Error Context

Error context dataclass for scheduler job failures.

SchedulerErrorContext dataclass

Bases: ErrorContext

Context passed to scheduler error handlers when a job raises an exception.

Attributes:

Name Type Description
exception BaseException

The exception that was raised by the job.

traceback str

Formatted traceback string.

job_name str

The name of the job function that raised the exception.

job_group str | None

The group the job belongs to, or None if ungrouped.

args tuple[Any, ...]

Positional arguments the job was scheduled with.

kwargs dict[str, Any]

Keyword arguments the job was scheduled with.

Source code in src/hassette/scheduler/error_context.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
@dataclass(frozen=True)
class SchedulerErrorContext(ErrorContext):
    """Context passed to scheduler error handlers when a job raises an exception.

    Attributes:
        exception: The exception that was raised by the job.
        traceback: Formatted traceback string.
        job_name: The name of the job function that raised the exception.
        job_group: The group the job belongs to, or None if ungrouped.
        args: Positional arguments the job was scheduled with.
        kwargs: Keyword arguments the job was scheduled with.
    """

    job_name: str
    job_group: str | None
    args: tuple[Any, ...]
    kwargs: dict[str, Any]

    @property
    def _domain_label(self) -> str:
        return f"job={self.job_name}"