SlackException#

exception safir.slack.blockkit.SlackException(message, user=None, *, failed_at=None)#

Bases: Exception

Parent class of exceptions that can be reported to Slack.

Intended to be subclassed. Subclasses may wish to override the to_slack method.

message#

Error message represented by this exception.

user#

Username associated with the exception.

failed_at#

When the failure occurred. Defaults to the time the exception was created.

Parameters:
  • message (str) – Exception string value, which is the default Slack message.

  • user (str | None, default: None) – Identity of user triggering the exception, if known.

  • failed_at (datetime | None, default: None) – When the exception happened. Omit to use the current time.

to_slack()#

Format the exception as a Slack message.

This is the generic version that only reports the text of the exception and the base fields. Child exceptions may want to override it to add more metadata.

Returns:

Slack message suitable for posting with safir.slack.webhook.SlackWebhookClient.

Return type:

SlackMessage