code: def catch(future, on_failure=None):
      """Close equivalent to ``then(future, None, on_failure)``.
  
      Args:
          future: Input future instance.
          on_failure: Function to be called once the input future completes with
              failure. Once the input future finish running with failure, its
              exception value is the input argument for *on_failure*.
              If *on_failure* returns a `Future` instance, the result future is
              chained to the output future. Otherwise, if *on_failure* returns an
              `Exception` instance, it is set as the exception of the output
              future.  Otherwise, the result of *on_failure* is set as the result
              of the output future.
              If *on_failure* is ``None``, the output future is set as failed
              with the exception from the input future.
  
      Returns:
          Output future instance to be completed once the input future is
          completed and *on_failure* completes.
  
      """
      if on_failure is None:
          return then(future, None, lambda exc: None)
      return then(future, None, on_failure)
  
file_path: mpi4py/src/mpi4py/futures/aplus.py
imports: import functools
  import threading
  import weakref
  from ._base import Future
label_desc: Use image node_id 2 for calling a global function with example usage: catch(future, on_failure) and returns: then, then