def METHOD_NAME(limit: Optional[int] = None, chain: bool = True) -> str:
    """Like print_exc() but return a string.
    :param limit: None to include all frames or the number of frames to include.
    :type limit: Optional[int]
    :param chain: Whether to format __cause__ and __context__. Defaults to True
    :type chain: bool
    :return: The formatted exception string
    :rtype: str
    """
    return "".join(format_exception(*sys.exc_info(), limit=limit, chain=chain))