On 13/10/20 10:16 am, jmward01@gmail.com wrote:
class MySpecialException(Exception): def __init__(self, some, variables, i, am, tracking): self.some = some ... ... try: if some_test_that_fails(variables): raise MySpecialException(a, b, c, d, e, f) except MySpecialException as e: logger.warning(f"BAD THING {e.a} HAPPENED!") if not handle_it(e.a, e.b, e.c, e.f): raise ...
You can reduce the amount of boilerplate by doing something like this: class MySpecialException(Exception): pass def handle_my_special_exception(a, b, c, d, e, f): .... try: if some_test_that_fails(variables): raise MySpecialException(a, b, c, d, e, f) except MySpecialException as e: if not handle_my_special_exception(*e.args): raise -- Greg