code: def _format_msg(text, width, indent=0, prefix=""):
      r
      text = repr(text).replace("`", "\\`").replace("\\n", " ``\\n`` ")
      sindent = " " * indent if not prefix else prefix
      wrapped_text = textwrap.wrap(text, width, subsequent_indent=sindent)
      # [1:-1] eliminates quotes generated by repr in first line
      return ("\n".join(wrapped_text))[1:-1].rstrip()
docs: r"""
      Format exception message.
  
      Replace newline characters \n with ``\n``, ` with \` and then wrap text as
      needed