code: def _run_with_exception_handler(cmdlineargs):
      """Execute the command and perform some reporting
      normalization if it crashes, but otherwise just let it go"""
      # otherwise - guard and only log the summary. Postmortem is not
      # as convenient if being caught in this ultimate except
      try:
          return cmdlineargs.func(cmdlineargs)
      # catch BaseException for KeyboardInterrupt
      except BaseException as exc:
          from datalad.support.exceptions import (
              CapturedException,
              CommandError,
              IncompleteResultsError,
              InsufficientArgumentsError,
          )
  
          ce = CapturedException(exc)
          # we crashed, it has got to be non-zero for starters
          exit_code = 1
          if isinstance(exc, InsufficientArgumentsError):
              # if the func reports inappropriate usage, give help output
              lgr.error("%s (%s)", ce, exc.__class__.__name__)
              cmdlineargs.subparser.print_usage(sys.stderr)
              exit_code = 2
          elif isinstance(exc, IncompleteResultsError):
              # in general we do not want to see the error again, but
              # present in debug output
              lgr.debug(
                  "could not perform all requested actions: %s", ce
              )
          elif isinstance(exc, CommandError):
              exit_code = _communicate_commanderror(exc) or exit_code
          elif isinstance(exc, KeyboardInterrupt):
              from datalad.ui import ui
  
              ui.error(
                  "\nInterrupted by user while doing magic: %s" % ce
              )
              exit_code = 3
          else:
              # some unforeseen problem
              lgr.error("%s", ce.format_with_cause())
          sys.exit(exit_code)
  
file_path: datalad/datalad/cli/main.py
imports: import logging
  import os
  import sys
  import datalad
  from .parser import setup_parser
label_desc: Use image node_id 5 for calling a global function with example usage: _run_with_exception_handler(cmdlineargs) and returns: cmdlineargs