https://prefect.io logo
d

Dolor Oculus

11/18/2020, 9:32 PM
Hi, I am working on a slack handler where I want to be notified only if the overall flow failed, not individual tasks. This is for a flow that is being registered via an agent, not run directly. I was looking at https://docs.prefect.io/core/advanced_tutorials/slack-notifications.html#customizing-your-alerts but it appears to be at task level, not flow level. Is there a good example in the docs for being notified on flow failure? ty!
z

Zanie

11/18/2020, 9:41 PM
Hi! The
Flow
object also supports
state_handlers
d

Dolor Oculus

11/18/2020, 9:41 PM
Ah! Checking now, ty
z

Zanie

11/18/2020, 9:41 PM
Also an
on_failure
callback 🙂
d

Dolor Oculus

11/18/2020, 9:42 PM
nice, even better. is there an example in the docs?
(wondering what args it gets)
z

Zanie

11/18/2020, 9:43 PM
You can take a look at the description at https://docs.prefect.io/api/latest/core/flow.html#flow-2
d

Dolor Oculus

11/18/2020, 9:44 PM
Copy code
on_failure (Callable, optional): A function with signature fn(flow: Flow, state: State) -> None which will be called anytime this Flow enters a failure state
cool -- trying out now
worked well enough - we were sad to see that the call stack of the uncaught 1/0 divide by zero exception didn't make its way through, but at least we have a way to know it failed!