Skip to content

Conversation

@andystaples
Copy link
Contributor

@andystaples andystaples commented Jan 7, 2026

Also improves new_failure_details to allow capturing inner exceptions

if self._exception is None:
raise ValueError('The task has not failed.')
return self._exception

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add another override here for failing a task that automatically takes in an Exception and handles all internal things needed by DurableTask to ensure that the failure is handled correctly?

Example:

def fail(self, ex: Exception):
  self._is_complete = True
              self._exception = TaskFailedError(
                  "Error occured",
                  ex
              )
              if self._parent is not None:
                  self._parent.on_child_completed(self)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the signature of CompletableTask.fail() to allow Exceptions as input, it'll handle things from there.
Choosing not to add an implementation of fail() to Task, as it violates the design of having CompletableTask vs CompositeTask. If an externally-defined class inheriting from CompositeTask needs to call fail(), it can double-inherit from CompletableTask (which more correctly describes the behavior of that task anyway).

@andystaples andystaples merged commit e8b163e into main Jan 8, 2026
20 checks passed
@andystaples andystaples deleted the andystaples/improve-task-failure-logic branch January 8, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants