code: def safe_output(fn, opts, task, *args, **kwargs):
      
      try:
          return fn(task, *args, **kwargs)
      except Exception as e:
          if opts["skip"] is None or not isinstance(e, opts["skip"]):
              for outp in luigi.task.flatten(task.output()):
                  outp.remove()
          raise
docs: safe_output(skip=None)
      Wraps a bound method of a task and guards its execution. If an exception occurs, and it is not
      an instance of *skip*, the task's output is removed prior to the actual raising.