Simple Exception Handler Decorator
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file exception_handler_plus-0.1.0.tar.gz.
File metadata
- Download URL: exception_handler_plus-0.1.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
512f7272bb6a5656c50007f9911396e5b71237d43a047dfc19bed837c164c9ef
|
|
| MD5 |
500c2089be5cbf30279f5ccf77eef23a
|
|
| BLAKE2b-256 |
a3e120d238e2cc0c968837d72b94b325c34442f079d92f2021581fa7d70a821e
|
File details
Details for the file exception_handler_plus-0.1.0-py3-none-any.whl.
File metadata
- Download URL: exception_handler_plus-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f97edd9101a70e1039ed49382b113fad5fb44db2b50bb209447d3d43819eeec
|
|
| MD5 |
5137d030d01e71714314173d701bef2c
|
|
| BLAKE2b-256 |
45f03e5c6b50db438916611ae2bf489cbcfc320ab7ed402736c626515c8426bd
|