Alberto de Santos

10/17/2020, 2:02 PM
I am using a map for a set of elements (let’s call them COUNTRY_ID), then, for specific countries, the task failed (and it should failed), however, I would like to catch that error some how and deal with it properly using Prefect. I have read all the doc regarding Handlers, Results and stuff like this. However, I am still struggling to understand which is the best option to, let’s say in my own words, do a try/except in Prefect.


10/17/2020, 4:24 PM
@Alberto de Santos you had a chance to look at triggers and/or signals? I think one of those could be really useful for catching the errors you're looking for and doing something when they occur.

Alberto de Santos

10/17/2020, 8:08 PM
Yes, @nicholas, I had a look to them, but not sure if that’s what I am looking for.
My question precisely is the following: Given a
done in Prefect, is triggers/signals something I can use so that, regardless they fail or not, I can handle them properly, so that the task ends SUCCESSFULY?
In other words, how to deal with FAILED in a


10/19/2020, 1:55 PM
@Alberto de Santos - would a second map with on the return values from the first work? Maybe something like this:
Copy code
import prefect
from prefect import Flow, task

def return_list():
    return [1, 2, 3, 4]

def parse_value(val):
    if val % 2 != 0:
        raise ValueError("Value is not even!")

    return val

def catch_error(val):
    print(f"Do something with this value error: {val}")

with Flow("Raise error on Odd") as flow:
    my_list = return_list()

    def_list =
Which should throw 2 errors and
will run twice with the value of the error