errors.py 文件源码

python
阅读 43 收藏 0 点赞 0 评论 0

项目:coquery 作者: gkunter 项目源码 文件源码
def print_exception(exc):
    """
    Prints the exception string to StdErr. XML tags are stripped.
    """
    error_string = ""
    if isinstance(exc, Exception):
        if not isinstance(exc, NoTraceException):
            _, _, error_string, _ = get_error_repr(sys.exc_info())
            error_string = "TRACE:\n{}".format(error_string)
        error_string += "ERROR {}: {}\n".format(type(exc).__name__, exc)
    else:
        error_string = exc

    for par in [x.strip(" ") for x in error_string.split("</p>") if x.strip(" ")]:
        par = par.replace("\n", " ").strip(" ")
        par = par.replace("  ", " ")
        print("\n".join(
            textwrap.wrap(re.sub('<[^>]*>', '', par), width=70, replace_whitespace=False)),
            file=sys.stderr)
        print(file=sys.stderr)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号