def _exception_gather_guard(self, fn):
@functools.wraps(fn)<EOL>def wrapper(*args, **kwargs):<EOL><INDENT>try:<EOL><INDENT>return fn(*args, **kwargs)<EOL><DEDENT>except UserException as e:<EOL><INDENT>self.exceptions.append(e)<EOL><DEDENT><DEDENT>return wrapper<EOL>
A higher order function to trap UserExceptions and then log them.

This is to present nicer output to the user when failures are
occuring in another thread of execution that may not end up at
the catch-all try/except in main().