def METHOD_NAME(self, exc: Exception, limit: int = 7) -> str:
    traceback_obj = traceback.TracebackException.from_exception(
        exc, capture_locals=True
    )
    exc_html = ""
    is_collapsed = False
    exc_traceback = exc.__traceback__
    if exc_traceback is not None:
        frames = inspect.getinnerframes(exc_traceback, limit)
        for frame in reversed(frames):
            exc_html += self.generate_frame_html(frame, is_collapsed)
            is_collapsed = True
    # escape error class and text
    error = (
        f"{html.escape(traceback_obj.exc_type.__name__)}: "
        f"{html.escape(str(traceback_obj))}"
    )
    return TEMPLATE.format(styles=STYLES, js=JS, error=error, exc_html=exc_html)