decorators.py 文件源码

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

项目:Sentry 作者: NetEaseGame 项目源码 文件源码
def less_shitty_error_messages(func):
    """
    Wraps functions where the first param is a SQL statement and enforces
    any exceptions thrown will also contain the statement in the message.
    """
    @wraps(func)
    def inner(self, sql, *args, **kwargs):
        try:
            return func(self, sql, *args, **kwargs)
        except Exception as e:
            exc_info = sys.exc_info()
            msg = '{}\nSQL: {}'.format(
                e.message,
                sql,
            )
            six.reraise(exc_info[0], exc_info[0](msg), exc_info[2])
    return inner
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号