code: def format_and_raise(
      exc: Exception, msg: str, path: str
  ) -> "NoReturn":
      spacing = (
          "\n"
          if isinstance(
              exc, (ParseError, MergeError, VarsAlreadyLoaded)
          )
          else " "
      )
      message = _format_preamble(msg, path, spacing) + str(exc)
  
      # FIXME: cannot reraise because of how we log "cause" of the exception
      # the error message is verbose, hence need control over the spacing
      _reraise_err(ResolveError, message, from_exc=exc)
  
imports: import logging
  import os
  from collections.abc import Mapping, Sequence
  from copy import deepcopy
  from itertools import product
  from typing import TYPE_CHECKING, Any, Dict, List, NamedTuple, Optional, Tuple, Type, Union
  from funcy import collecting, first, isa, join, reraise
  from dvc.exceptions import DvcException
  from dvc.log import logger
  from dvc.parsing.interpolate import ParseError
  from dvc.utils.objects import cached_property
  from .context import Context, ContextError, KeyNotInContext, MergeError, Node, VarsAlreadyLoaded
  from .interpolate import check_recursive_parse_errors, is_interpolated_string, recurse, to_str
label_desc: Use image node_id 2 for calling a global function with example usage: format_and_raise(exc, msg, path) without return types