-
Notifications
You must be signed in to change notification settings - Fork 22
Allow TaskFailedError to be constructed from Exception #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| if self._exception is None: | ||
| raise ValueError('The task has not failed.') | ||
| return self._exception | ||
|
|
There was a problem hiding this comment.
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)There was a problem hiding this comment.
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).
Also improves new_failure_details to allow capturing inner exceptions