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.
Metadata
Release files for minder 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| minder-0.0.2.tar.gz | 4.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| minder-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.7 kB
Release files / minder-0.0.2.tar.gz
| Download URL | minder-0.0.2.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
928c48a83744a2e68846c7b1b5d6e53e3d56740584e61936c70ac636ef38c80c
|
|
BLAKE2b-256 checksum How to use checksums |
a88cdf1327d97897ba81d619095731761c7cee40fb92732e46676e0350edc442
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.12.3 CPython/3.11.5
|
Release files / minder-0.0.2-py3-none-any.whl
| Download URL | minder-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d97777f08ba7088abeabf50ad8863dc299a801cff0bfc242f23540eb29a9eb6
|
|
BLAKE2b-256 checksum How to use checksums |
6c315b019178f908516756305717bd072b51ad985f0afac26836c9e2f661db3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.12.3 CPython/3.11.5
|