Skip to main content

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)

Source distribution for exception-handler-plus 0.1.0
File Size Uploaded
exception_handler_plus-0.1.0.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for exception-handler-plus 0.1.0
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page