Skip to content

APIs

The Minder context manager is given a Duty for the duration of its context block.

It exits without raising if an error is encountered by recording it in error.

Minder

Minder()

Exceptions raised in this ContextManager become stored as error.

Attributes:

Name Type Description
result

A dict which holds the result.

failed

A flag indicating whether the operation failed.

result instance-attribute

result = {}

failed instance-attribute

failed = False

duty

duty(where: str, recoverable: bool = False) -> Duty

Prepare to record a Duty associated with this result.

record_breach

record_breach(where: str, error: str) -> None

Record the serialised error message and its location where in the result.

record_result

record_result(result) -> None

Record a positive result.

report

report() -> dict

Provide a simple interface: result and success bool.

If the operation failed the result will be a dict of an error message and where (the location of the Duty in which the exception raised).

Duty

Duty(mgr: Minder, where: str, recoverable: bool)

Ensures any exception is handled and stored in result upon early exit.

Prepare to report where the breach occurred, and whether to suppress the exception (if recoverable the error will not halt further execution upon exit of the Duty context manager block).

mgr instance-attribute

mgr: Minder = mgr

where instance-attribute

where: str = where

recoverable instance-attribute

recoverable: bool = recoverable