<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _exception_gather_guard(self, fn):
 """ 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(). """


        @functools.wraps(fn)
        def wrapper(*args, **kwargs):
            try:
                return fn(*args, **kwargs)
            except UserException as e:
                self.exceptions.append(e)

        return wrapper