1#!/usr/bin/env python3
2"""
3These are the doot specific errors that can occur
4"""
5# Imports:
6from __future__ import annotations
7
8# ##-- stdlib imports
9import logging as logmod
10from typing import (TYPE_CHECKING, Any, Callable, ClassVar, Final, Generator,
11 Generic, Iterable, Iterator, Mapping, Match,
12 MutableMapping, Protocol, Sequence, Tuple, TypeAlias,
13 TypeGuard, TypeVar, cast, final, overload,
14 runtime_checkable)
15
16# ##-- end stdlib imports
17
18from ._base import DootError, BackendError
19
20if TYPE_CHECKING:
21 from jgdv import Maybe
22 from doot.workflow._interface import Task_i
23
24##-- logging
25logging = logmod.getLogger(__name__)
26##-- end logging
27
28# ##-- Generated Exports
29__all__ = ( # noqa: RUF022
30
31# -- Classes
32"ActionCallError", "ActionStateError", "ControlError", "JobExpansionError",
33"TaskExecutionError", "TrackingError",
34
35)
36# ##-- end Generated Exports
37
[docs]
38class ControlError(BackendError):
39 pass
40
[docs]
41class TrackingError(ControlError):
42 """ The underlying sequencing of task running failed in some way. """
43 general_msg : str = "Doot Tracking Failure:"
44 pass
45
[docs]
46class TaskExecutionError(ControlError):
47 """ An Error indicating a specific task failed """
48 general_msg = "Doot Task Error:"
49
50 def __init__(self, msg:str, *args:Any, task:Maybe[Task_i]=None):
51 super().__init__(msg, *args)
52 self.task = task
53
[docs]
54 @property
55 def task_name(self):
56 if not self.task:
57 return ""
58 return self.task.name
59
[docs]
60 @property
61 def task_source(self):
62 if not self.task:
63 return ""
64 match [x for x in self.task.sources if x is not None]:
65 case []:
66 return ""
67 case [*xs, x]:
68 return x
69
[docs]
70class JobExpansionError(TaskExecutionError):
71 pass
72
[docs]
73class ActionCallError(TaskExecutionError):
74 """ In the course of executing a task, one of it's actions failed. """
75 general_msg = "Doot Action Failure:"
76 pass
77
[docs]
78class ActionStateError(ActionCallError):
79 """ An action required certain state to exist, but it wasn't found. """
80 general_msg = "Doot Action State Fields Missing:"
81 pass