Ensurers - capture_exception
Small amendment to v0.6.0: ensurers can now capture the exception when called directly, so they can be used in if
statements easily.
# This will not raise an Exception is the check fails
if self._ensure_connected(capture_exception=True):
print("laser is connected!")
Original v0.6.0 changelog follows:
An ensurer is a decorator that can be placed on getters, setters, and actions, and it will run ahead of these functions. The intended behaviour is performing checks ahead of running the function - for example checking if a laser is connected ahead of trying to set its power. This way one ensurer can be written and used in multiple places easily.
See https://puzzlepiece.readthedocs.io/en/latest/puzzlepiece.piece.html#puzzlepiece.piece.ensurer for examples