Hi, I am working on a slack handler where I want t...
# prefect-community
d
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
Hi! The
Flow
object also supports
state_handlers
d
Ah! Checking now, ty
z
Also an
on_failure
callback 🙂
d
nice, even better. is there an example in the docs?
(wondering what args it gets)
z
You can take a look at the description at https://docs.prefect.io/api/latest/core/flow.html#flow-2
d
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!