code: def _try_command(record, fn, *args, **kwargs):
      """Call `fn`, catching a `CommandError`.
  
      Parameters
      ----------
      record : dict
          A partial result record. It should at least have 'action' and 'message'
          fields. A 'status' value of 'ok' or 'error' will be added based on
          whether calling `fn` raises a `CommandError`.
  
      Returns
      -------
      A new record with a 'status' field.
      """
      try:
          fn(*args, **kwargs)
      except CommandError as exc:
          ce = CapturedException(exc)
          return dict(record, status="error", message=str(ce))
      else:
          return dict(record, status="ok")
  
imports: import logging
  from os.path import lexists
  import itertools
  from datalad.interface.base import Interface
  from datalad.interface.base import build_doc, eval_results
  from datalad.interface.results import get_status_dict, YieldDatasets
  from datalad.support.constraints import EnsureBool, EnsureChoice, EnsureStr, EnsureNone
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import CapturedException, CommandError
  from datalad.support.param import Parameter
  from datalad.interface.common_opts import recursion_flag, recursion_limit
  from datalad.distribution.dataset import require_dataset
  from .dataset import EnsureDataset, datasetmethod
label_desc: Use image node_id 5 for calling a global function with example usage: _try_command(record, fn) and returns: dict, dict