Define exception handling logic via a decorator.
Project description
WrapErr
The goal of WrapErr is to avoid contaminating main logic with try-catch blocks and the exception handling logic.
Without WrapErr, you have something like this:
try:
// do something
except Exception as e:
// exception handling logic
With WrapErr, you would write something more like this:
def error_handler(e: Exception):
// exception handling logic
@wrap_error(error_handler)
def foo(*args, **kwargs):
// do something
You can reuse the same error handling logic across multiple functions and methods:
def error_handler(e: Exception):
// exception handling logic
@wrap_error(error_handler)
def foo(*args, **kwargs):
// do something
@wrap_error(error_handler):
def bar(*args, **kwargs):
// do something else
You can also only handle exceptions of a specific type:
def value_error_handler(e: ValueError):
// exception handling logic
@wrap_error(error_handler, ValueError)
def foo(*args, **kwargs):
// do something
And you can combine different error handlers that handle different exceptions:
def value_error_handler(e: ValueError):
// exception handling logic
def attribute_error_handler(e: AttributeError):
// more exception handling logic
@wrap_error(value_error_handler, ValueError)
@wrap_error(attribute_error_handler, AttributeError)
def foo(*args, **kwargs):
// do something
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 wraperr-1.0.0.tar.gz.
File metadata
- Download URL: wraperr-1.0.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e24a2ea7ee9ebb44417cfa6c341fe92e23a44cc3bb9ca184512dc5471464c884
|
|
| MD5 |
9e371a30fd49c13ed7cb9786e47cacbf
|
|
| BLAKE2b-256 |
523de4ef92a93685ade0ab907c6b3fd7ba43af25fef60edff6f2419597b19bc7
|
File details
Details for the file wraperr-1.0.0-py3-none-any.whl.
File metadata
- Download URL: wraperr-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c21c9923806018d9ec8765ddeb274846790b4831599abca8e71e6c5ccd99dc6f
|
|
| MD5 |
9aef42fc1547d5d13451ea7cf37c22f4
|
|
| BLAKE2b-256 |
2b0d13011b8248386afa752988d59f1cfb6fd1b69457152db73518a3985d879e
|