code: def exception_handler(func: Callable[..., Any]) -> Callable[..., Any]:  # type: ignore[misc]
      """Decorator to handle exceptions."""
  
      @wraps(func)
      def wrapper(*args: Any, **kwargs: Any) -> Any:  # type: ignore[misc]
          try:
              func(*args, **kwargs)
          except Exception as e:
              # This will log to the file handlers registered in the root.
              logging.exception(
                  "Got an exception in the exception handler."
              )
              # Checks if CLIContext has verbose flag set
  
              if isinstance(args[0], CLIContext):
                  cli_context: CLIContext = args[0]
                  click.echo(
                      f"\nERROR: {str(e)}\nLog file: {cli_context.log_file_path}"
                  )
              else:
                  if not isinstance(args[0], CLIContext):
                      logger.error(
                          f"Missing {CLIContext.__name__} as the first argument to the function "
                          f"{getattr(func, '__name__', repr(func))}"
                      )
                  click.echo(f"\nERROR: {str(e)}")
              if (
                  args
                  and hasattr(args[0], "verbose")
                  and args[0].verbose is True
              ):
                  click.echo(traceback.format_exc())
  
              exit(1)
  
      return wrapper
  
file_path: metricflow/metricflow/cli/utils.py
imports: from __future__ import annotations
  import datetime
  import logging
  import pathlib
  import traceback
  from functools import update_wrapper, wraps
  from typing import Any, Callable, List, Optional
  import click
  from dateutil.parser import parse
  import metricflow.cli.custom_click_types
  from metricflow.cli.cli_context import CLIContext
label_desc: Use image node_id 6 for calling a global function with example usage: exception_handler(func) and returns: wrapper