On 13/10/20 10:16 am, jmwar...@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
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/65LUX2K5UOATN4HH7RTKLOWYADQAORMQ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to