report_exception#
- async safir.sentry.report_exception(exc, slack_client)#
Notify Sentry and Slack about an exception.
Use this when you want to be notified about an exception, but stop propagating it. If you want to keep propagating the exception and still support both Slack and Sentry, catch the exception, use
post_exception
, re-raise the exception, and let the Sentry-configured uncaught exception handler notify Sentry if the exception makes it that far.If Sentry has not been initialized, then no events will be sent to Sentry. If
slack_client
isNone
, then no notifications will be sent to Slack.If the exception is an instance of
SlackIgnoredException
, no notifications will be sent to either Sentry or Slack. If the exception is an instance ofSlackException
, the Slack message will be generated from itsto_slack
method.- Parameters:
exc (
Exception
) – The Exception to send to the notification service.slack_client (
SlackWebhookClient
|None
) – A client to use to send a Slack notification about the exception. If this isNone
, then no Slack notification will be sent.
- Return type: