pawnlib.exceptions package

from pawnlib.exceptions import *

Submodules

pawnlib.exceptions.notifier module

from pawnlib.exceptions import notifier
class ExceptionNotifier(logger=None, slack_status='failed', slack_msg_level='error', slack_icon=':alert:', slack_url=None)[source]

Bases: LoggerMixin

Initializes the ExceptionNotifier with logging and Slack notification settings.

Parameters:
  • logger (optional) – Logger instance to log the error. |default| None

  • slack_status (optional) – Status type for Slack notification (default: ‘error’). |default| 'failed'

  • slack_msg_level (optional) – Message level for Slack (default: ‘error’). |default| 'error'

  • slack_icon (optional) – Emoji icon for Slack message (default: ‘:alert:’). |default| ':alert:'

  • slack_url (optional) – The Slack webhook URL. If None, it will use the environment variable. |default| None

__init__(logger=None, slack_status='failed', slack_msg_level='error', slack_icon=':alert:', slack_url=None)[source]

Initializes the ExceptionNotifier with logging and Slack notification settings.

Parameters:
  • logger (optional) – Logger instance to log the error. |default| None

  • slack_status (optional) – Status type for Slack notification (default: ‘error’). |default| 'failed'

  • slack_msg_level (optional) – Message level for Slack (default: ‘error’). |default| 'error'

  • slack_icon (optional) – Emoji icon for Slack message (default: ‘:alert:’). |default| ':alert:'

  • slack_url (optional) – The Slack webhook URL. If None, it will use the environment variable. |default| None

notify(e, additional_message=None)[source]

Logs the exception and sends a notification to Slack with detailed traceback.

Parameters:
  • e – Exception object.

  • additional_message (optional) – Additional message to send along with the exception details (optional). |default| None

notify_exception(e, logger=None, additional_message=None, slack_status='failed', slack_msg_level='error', slack_icon=':alert:', slack_url=None)[source]

A helper function to quickly notify an exception using the ExceptionNotifier.

Parameters:
  • e – Exception object.

  • logger (optional) – Logger instance (optional). |default| None

  • additional_message (optional) – Additional message to send along with the exception details (optional). |default| None

  • slack_status (optional) – Status type for Slack notification (default: ‘error’). |default| 'failed'

  • slack_msg_level (optional) – Message level for Slack (default: ‘error’). |default| 'error'

  • slack_icon (optional) – Emoji icon for Slack message (default: ‘:alert:’). |default| ':alert:'

  • slack_url (optional) – Slack webhook URL. If None, it will use the environment variable (optional). |default| None