future-hospital-70237
06/11/2025, 3:47 AMjolly-florist-66728
06/11/2025, 3:47 AMfuture-hospital-70237
06/11/2025, 3:48 AMjolly-florist-66728
06/11/2025, 3:48 AMfuture-hospital-70237
06/11/2025, 6:17 AMjolly-florist-66728
06/11/2025, 6:17 AMfuture-hospital-70237
06/11/2025, 6:21 AMjolly-florist-66728
06/11/2025, 6:21 AMfrom flytekit import task
from flytekit.experimental import eager
from flytekit.exceptions.eager import EagerException
@task
def add_one(x: int) -> int:
if x < 0:
raise ValueError("x must be positive")
return x + 1
@eager
async def eager_workflow(x: int) -> int:
try:
out = await add_one(x=x)
except EagerException:
# Handle the error, e.g., return a default value or log
return -1
return out
In this example, if add_one raises an exception, it is caught as EagerException, and you can handle it as you would in normal Python code. This is not possible in standard workflows, where you would need to use failure nodes or set workflow failure policies, but cannot catch exceptions inline. See Catching exceptions in eager workflows and EagerException API reference.
Sources:
- Failure node
- EagerException API reference
- Workflows versus tasks under the hood π 0 button π 0 button π‘ Hint: Mention @runllm in the thread for followups.future-hospital-70237
06/11/2025, 7:12 AMjolly-florist-66728
06/11/2025, 7:12 AMfuture-hospital-70237
06/11/2025, 7:13 AMunexpected resource type task for identifier xxx, expected workflow instead
@ancient-wolf-19325jolly-florist-66728
06/11/2025, 7:13 AM