cli.py 文件源码

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

项目:pib 作者: datawire 项目源码 文件源码
def handle_unexpected_errors(f):
    """Decorator that catches unexpected errors."""

    @wraps(f)
    def call_f(*args, **kwargs):
        try:
            return f(*args, **kwargs)
        except Exception as e:
            errorf = StringIO()
            print_exc(file=errorf)
            error = errorf.getvalue()
            click.echo(
                "Looks like there's a bug in our code. Sorry about that!"
                " Here's the traceback:\n" + error)
            if click.confirm(
                    "Would you like to file an issue in our issue tracker?",
                    default=True, abort=True):
                url = "https://github.com/datawire/pib/issues/new?body="
                body = quote_plus(BUG_REPORT_TEMPLATE.format(
                    os.getcwd(), __version__, python_version,
                    run_result(["uname", "-a"]), error))
                webbrowser.open_new(url + body)

    return call_f
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号