in azure/durable_functions/models/Task.py [0:0]
def set_value(self, is_error: bool, value: Any):
"""Set the value of this Task: either an exception of a result.
Parameters
----------
is_error : bool
Whether the value represents an exception of a result.
value : Any
The value of this Task
Raises
------
Exception
When the Task failed but its value was not an Exception
"""
new_state = self.state
if is_error:
if not isinstance(value, Exception):
if not (isinstance(value, TaskBase) and isinstance(value.result, Exception)):
err_message = f"Task ID {self.id} failed but it's value was not an Exception"
raise Exception(err_message)
new_state = TaskState.FAILED
else:
new_state = TaskState.SUCCEEDED
self.change_state(new_state)
self.result = value
self.propagate()