Skip to content

Commit d1eca99

Browse files
committed
feat: add TaskFailed message to TaskFailureContext
Signed-off-by: Yves Bastide <yves@botify.com>
1 parent 0aa04b2 commit d1eca99

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

examples/failing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ def on_task_failure(self, failure_context: TaskFailureContext) -> TaskFailureCon
5454
colorize(
5555
YELLOW,
5656
f"FailingWorkflow.on_task_failure: {failure_context.task_name}: {failure_context.exception!r}"
57-
f" (started_id: {failure_context.event.get('started_id')})",
57+
f" (started_id: {failure_context.event.get('started_id')})"
58+
f" message: {failure_context.task_message!r}"
59+
f" {failure_context.task_error!r} ({failure_context.task_error_type})",
5860
)
5961
)
6062
return None # no specific handling

simpleflow/task.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ class Decision(Enum):
318318
reason: str | None = attr.ib(default=None)
319319
details: Any = attr.ib(default=None)
320320
task_error: str | None = attr.ib(default=None)
321+
task_message: str | None = attr.ib(default=None)
321322
task_error_type: type[Exception] | None = attr.ib(default=None)
322323

323324
def __attrs_post_init__(self):
@@ -334,6 +335,8 @@ def __attrs_post_init__(self):
334335
if isinstance(details, dict):
335336
if "error" in details:
336337
self.task_error = details["error"]
338+
if "message" in details:
339+
self.task_message = details["message"]
337340
if "error_type" in details:
338341
try:
339342
self.task_error_type = import_from_module(details["error_type"])

0 commit comments

Comments
 (0)