gwkokab.utils.exceptions ======================== .. py:module:: gwkokab.utils.exceptions .. autoapi-nested-parse:: Custom Logged Exceptions and Warnings for gwkokab. This module provides a registry of standard Python exceptions and warnings extended with automatic logging capabilities via `loguru `_. The mixin classes :class:`LoggedMixinException` and :class:`LoggedMixinWarning` provide the functionality to format and log messages for exceptions and warnings, respectively. The custom exception and warning classes inherit from these mixins and the corresponding built-in exception or warning classes. When an instance of these custom classes is created, the message is formatted using the provided arguments and keyword arguments, and then logged at the appropriate level (error for exceptions and warning for warnings). If formatting fails, the original message is used without formatting. This allows for consistent logging of error and warning messages throughout the application. You can use these custom exceptions and warnings in your code to automatically log messages when they are raised or issued. For example: .. code:: python import warnings from gwkokab.utils.exceptions import LoggedMixinException, LoggedMixinWarning class LoggedValueError(LoggedMixinException, ValueError): pass class LoggedUserWarning(LoggedMixinWarning, UserWarning): pass warnings.warn("This is a warning message", LoggedUserWarning) raise LoggedValueError("Invalid value: {value}", value=42) Exceptions ---------- .. autoapisummary:: gwkokab.utils.exceptions.LoggedAssertionError gwkokab.utils.exceptions.LoggedDeprecationWarning gwkokab.utils.exceptions.LoggedImportError gwkokab.utils.exceptions.LoggedIndexError gwkokab.utils.exceptions.LoggedKeyError gwkokab.utils.exceptions.LoggedNotImplementedError gwkokab.utils.exceptions.LoggedRuntimeWarning gwkokab.utils.exceptions.LoggedTypeError gwkokab.utils.exceptions.LoggedUserWarning gwkokab.utils.exceptions.LoggedValueError Classes ------- .. autoapisummary:: gwkokab.utils.exceptions.LoggedMixinException gwkokab.utils.exceptions.LoggedMixinWarning Module Contents --------------- .. py:exception:: LoggedAssertionError(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs) Bases: :py:obj:`LoggedMixinException`, :py:obj:`AssertionError` A mixin class for exceptions that logs the error message using loguru when the exception is instantiated. The message is formatted using the provided arguments and keyword arguments. If formatting fails, the original message is used without formatting. The formatted message is logged at the error level. Initialize self. See help(type(self)) for accurate signature. .. py:exception:: LoggedDeprecationWarning(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs) Bases: :py:obj:`LoggedMixinWarning`, :py:obj:`DeprecationWarning` A mixin class for warnings that logs the warning message using loguru when the warning is instantiated. The message is formatted using the provided arguments and keyword arguments. If formatting fails, the original message is used without formatting. The formatted message is logged at the warning level. Initialize self. See help(type(self)) for accurate signature. .. py:exception:: LoggedImportError(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs) Bases: :py:obj:`LoggedMixinException`, :py:obj:`ImportError` A mixin class for exceptions that logs the error message using loguru when the exception is instantiated. The message is formatted using the provided arguments and keyword arguments. If formatting fails, the original message is used without formatting. The formatted message is logged at the error level. Initialize self. See help(type(self)) for accurate signature. .. py:exception:: LoggedIndexError(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs) Bases: :py:obj:`LoggedMixinException`, :py:obj:`IndexError` A mixin class for exceptions that logs the error message using loguru when the exception is instantiated. The message is formatted using the provided arguments and keyword arguments. If formatting fails, the original message is used without formatting. The formatted message is logged at the error level. Initialize self. See help(type(self)) for accurate signature. .. py:exception:: LoggedKeyError(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs) Bases: :py:obj:`LoggedMixinException`, :py:obj:`KeyError` A mixin class for exceptions that logs the error message using loguru when the exception is instantiated. The message is formatted using the provided arguments and keyword arguments. If formatting fails, the original message is used without formatting. The formatted message is logged at the error level. Initialize self. See help(type(self)) for accurate signature. .. py:exception:: LoggedNotImplementedError(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs) Bases: :py:obj:`LoggedMixinException`, :py:obj:`NotImplementedError` A mixin class for exceptions that logs the error message using loguru when the exception is instantiated. The message is formatted using the provided arguments and keyword arguments. If formatting fails, the original message is used without formatting. The formatted message is logged at the error level. Initialize self. See help(type(self)) for accurate signature. .. py:exception:: LoggedRuntimeWarning(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs) Bases: :py:obj:`LoggedMixinWarning`, :py:obj:`RuntimeWarning` A mixin class for warnings that logs the warning message using loguru when the warning is instantiated. The message is formatted using the provided arguments and keyword arguments. If formatting fails, the original message is used without formatting. The formatted message is logged at the warning level. Initialize self. See help(type(self)) for accurate signature. .. py:exception:: LoggedTypeError(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs) Bases: :py:obj:`LoggedMixinException`, :py:obj:`TypeError` A mixin class for exceptions that logs the error message using loguru when the exception is instantiated. The message is formatted using the provided arguments and keyword arguments. If formatting fails, the original message is used without formatting. The formatted message is logged at the error level. Initialize self. See help(type(self)) for accurate signature. .. py:exception:: LoggedUserWarning(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs) Bases: :py:obj:`LoggedMixinWarning`, :py:obj:`UserWarning` A mixin class for warnings that logs the warning message using loguru when the warning is instantiated. The message is formatted using the provided arguments and keyword arguments. If formatting fails, the original message is used without formatting. The formatted message is logged at the warning level. Initialize self. See help(type(self)) for accurate signature. .. py:exception:: LoggedValueError(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs) Bases: :py:obj:`LoggedMixinException`, :py:obj:`ValueError` A mixin class for exceptions that logs the error message using loguru when the exception is instantiated. The message is formatted using the provided arguments and keyword arguments. If formatting fails, the original message is used without formatting. The formatted message is logged at the error level. Initialize self. See help(type(self)) for accurate signature. .. py:class:: LoggedMixinException(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs) A mixin class for exceptions that logs the error message using loguru when the exception is instantiated. The message is formatted using the provided arguments and keyword arguments. If formatting fails, the original message is used without formatting. The formatted message is logged at the error level. .. py:class:: LoggedMixinWarning(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs) A mixin class for warnings that logs the warning message using loguru when the warning is instantiated. The message is formatted using the provided arguments and keyword arguments. If formatting fails, the original message is used without formatting. The formatted message is logged at the warning level.