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
minder-0.0.2.tar.gz
(4.3 kB
view hashes)
Built Distribution
minder-0.0.2-py3-none-any.whl
(4.4 kB
view hashes)