diff --git a/src/controlflow/core/task.py b/src/controlflow/core/task.py index 74a60fed..b5fc333e 100644 --- a/src/controlflow/core/task.py +++ b/src/controlflow/core/task.py @@ -302,10 +302,10 @@ def run(self, max_iterations: int = NOTSET) -> T: ) self.run_once() counter += 1 - if self.is_successful(): - return self.result - elif self.is_failed(): - raise ValueError(f"{self.friendly_name()} failed: {self.error}") + if self.is_successful(): + return self.result + elif self.is_failed(): + raise ValueError(f"{self.friendly_name()} failed: {self.error}") @contextmanager def _context(self):