Exception guard capture utility library
Project description
Minder
Exception guard capture utility library.
Installation
pip install minder
Demo
The Minder context manager keeps failure modes contained with minimal legibility cost:
from minder import Minder
def succeed() -> dict:
with Minder() as guard:
with guard.duty("winning"):
guard.result = 100
return guard.report()
response = succeed()
print(response)
{'result': 100, 'success': True}
When an error is encountered, we get the same interface.
from minder import Minder
def fail() -> dict:
with Minder() as guard:
with guard.duty("greet"):
print("Hello world")
with guard.duty("division"):
guard.result = 1 / 0
return guard.report()
response = fail()
print(response)
Hello world
{'result': {'error': 'division by zero', 'where': 'division'}, 'success': False}
In this example we expose a reliable interface of a result and success boolean.
We could also return guard (the Minder instance) and handle success/failure at the call site,
but the assumption is we would rather have this prepared for us.
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 minder-0.0.2.tar.gz.
File metadata
- Download URL: minder-0.0.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.12.3 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
928c48a83744a2e68846c7b1b5d6e53e3d56740584e61936c70ac636ef38c80c
|
|
| MD5 |
4a63efd82f65691745a4a6e16ca531d2
|
|
| BLAKE2b-256 |
a88cdf1327d97897ba81d619095731761c7cee40fb92732e46676e0350edc442
|
File details
Details for the file minder-0.0.2-py3-none-any.whl.
File metadata
- Download URL: minder-0.0.2-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.12.3 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d97777f08ba7088abeabf50ad8863dc299a801cff0bfc242f23540eb29a9eb6
|
|
| MD5 |
23a4ccc209bba59ca797bd8ce92ab0c8
|
|
| BLAKE2b-256 |
6c315b019178f908516756305717bd072b51ad985f0afac26836c9e2f661db3e
|