<@ULVA73B9P> How do i specify an exception handler...
# ask-marvin
d
@Marvin How do i specify an exception handler for all of my flows? I'd like to catch exceptions and send them to slack
m
To specify an exception handler for all of your flows, you can create a new logging handler. The
handlers
section of the default
logging.yml
shows the existing log handlers: the
console
handler, and the
prefect server
handler that sends logs to the API. You can add a new handler here for handling exceptions. To send these exceptions to Slack, you can configure a notification in the Prefect server. Go to the Notifications page and select Create Notification or the + button. You can choose which run states should trigger a notification, tags to filter which flow runs are covered by the notification, and whether to send a Slack message. For Slack notifications, the configuration requires webhook credentials for your Slack and the channel to which the message is sent. Here are the resources for more details: - How to stream prefect logs to a file - Prefect Notifications Guide
d
Thanks Nate!
👍 1
looks like
Copy code
@flow(on_failure=[notify_slack], retries=1)