Exception Handler decorator allows developers to specify specific exception types to handle and provide a handler function for each of those exception types. The decorator also provides an option to specify a default return value to be used when an unhandled exception occurs. Additionally, the decorator tracks the number of times each exception type has been seen and raises a MaxRepeatedExceptionsError when a specific exception type exceeds a specified maximum number of occurrences.
The decorator uses the exception_handler function as a wrapper for the decorated function. The function accepts four parameters:
- handlers (Dict[Type[Exception], HandlerFuncType]): A dictionary where the keys are exception types and the values are the corresponding
- handler functions for those exception types.
- default_return (Optional[Any]): A default return value to be used when an unhandled exception occurs.
- max_repeated_exceptions (int): The maximum number of times an exception type can be seen before a MaxRepeatedExceptionsError is raised.
- seen_exceptions (Optional[DefaultDict[Type[Exception], List[int]]]): A defaultdict used to keep track of the number of times each exception type has been seen.
The read_env module is used to read the maximum number of repeated exceptions that can occur from an environment variable.
Metadata
Release files for exception-handler-plus 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| exception_handler_plus-0.1.0.tar.gz | 4.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| exception_handler_plus-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.0 kB
Release files / exception_handler_plus-0.1.0.tar.gz
| Download URL | exception_handler_plus-0.1.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
512f7272bb6a5656c50007f9911396e5b71237d43a047dfc19bed837c164c9ef
|
|
BLAKE2b-256 checksum How to use checksums |
a3e120d238e2cc0c968837d72b94b325c34442f079d92f2021581fa7d70a821e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Release files / exception_handler_plus-0.1.0-py3-none-any.whl
| Download URL | exception_handler_plus-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f97edd9101a70e1039ed49382b113fad5fb44db2b50bb209447d3d43819eeec
|
|
BLAKE2b-256 checksum How to use checksums |
45f03e5c6b50db438916611ae2bf489cbcfc320ab7ed402736c626515c8426bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|