gwkokab.utils.exceptions¶
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 LoggedMixinException and 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:
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¶
A mixin class for exceptions that logs the error message using loguru when the |
|
A mixin class for warnings that logs the warning message using loguru when the |
|
A mixin class for exceptions that logs the error message using loguru when the |
|
A mixin class for exceptions that logs the error message using loguru when the |
|
A mixin class for exceptions that logs the error message using loguru when the |
|
A mixin class for exceptions that logs the error message using loguru when the |
|
A mixin class for warnings that logs the warning message using loguru when the |
|
A mixin class for exceptions that logs the error message using loguru when the |
|
A mixin class for warnings that logs the warning message using loguru when the |
|
A mixin class for exceptions that logs the error message using loguru when the |
Classes¶
A mixin class for exceptions that logs the error message using loguru when the |
|
A mixin class for warnings that logs the warning message using loguru when the |
Module Contents¶
- exception gwkokab.utils.exceptions.LoggedAssertionError(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs)[source]¶
Bases:
LoggedMixinException,AssertionErrorA 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.
- exception gwkokab.utils.exceptions.LoggedDeprecationWarning(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs)[source]¶
Bases:
LoggedMixinWarning,DeprecationWarningA 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.
- exception gwkokab.utils.exceptions.LoggedImportError(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs)[source]¶
Bases:
LoggedMixinException,ImportErrorA 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.
- exception gwkokab.utils.exceptions.LoggedIndexError(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs)[source]¶
Bases:
LoggedMixinException,IndexErrorA 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.
- exception gwkokab.utils.exceptions.LoggedKeyError(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs)[source]¶
Bases:
LoggedMixinException,KeyErrorA 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.
- exception gwkokab.utils.exceptions.LoggedNotImplementedError(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs)[source]¶
Bases:
LoggedMixinException,NotImplementedErrorA 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.
- exception gwkokab.utils.exceptions.LoggedRuntimeWarning(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs)[source]¶
Bases:
LoggedMixinWarning,RuntimeWarningA 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.
- exception gwkokab.utils.exceptions.LoggedTypeError(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs)[source]¶
Bases:
LoggedMixinException,TypeErrorA 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.
- exception gwkokab.utils.exceptions.LoggedUserWarning(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs)[source]¶
Bases:
LoggedMixinWarning,UserWarningA 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.
- exception gwkokab.utils.exceptions.LoggedValueError(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs)[source]¶
Bases:
LoggedMixinException,ValueErrorA 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.
- class gwkokab.utils.exceptions.LoggedMixinException(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs)[source]¶
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.
- class gwkokab.utils.exceptions.LoggedMixinWarning(msg: str, *args, loguru_opt: dict[str, Any] = {'depth': 1}, **kwargs)[source]¶
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.