def METHOD_NAME(no_tb=False):
    e, v, tb = sys.exc_info()
    # This is needed when testing chaining and cause without traceback.
    # We set `err.__traceback__ = None` in tests and apparently that makes
    # `tb` here `None´ with Python 3.11 but not with others.
    if sys.version_info < (3, 11) and no_tb:
        tb = None
    return ''.join(traceback.format_exception(e, v, tb)).rstrip()