errors.py 文件源码

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

项目:coquery 作者: gkunter 项目源码 文件源码
def get_error_repr(exc_info):
    exc_type, exc_obj, exc_tb = exc_info
    Trace = traceback.extract_tb(exc_tb)
    trace_string = ""
    Indent = ""
    Text = ""
    for file_name, line_no, func_name, text in Trace:
        path, module_name = os.path.split(file_name)
        # only print exceptions from Coquery files:
        if any([path.startswith(x) for x in get_source_paths()]):
            trace_string += "{} {}, line {}: {}\n".format(
                Indent, module_name, line_no, func_name.replace("<", "&lt;"))
            Indent += "  "
    file_location = "{}, line {}".format(file_name, line_no)
    if text:
        trace_string += "%s> %s\n" % (Indent[:-1], text)
    return (exc_type, exc_obj, trace_string, file_location)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号