context_managers.py 文件源码

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

项目:Chiaki-Nanami 作者: Ikusaba-san 项目源码 文件源码
def redirect_exception(*exceptions, cls=ChiakiException):
    """Context manager to re-raise exceptions with a proxy exception class.

    The exceptions can either be an exception type or a (exc_type, string) pair.
    """
    exceptions = dict(exc if isinstance(exc, Sequence) else (exc, None)
                      for exc in exceptions)
    try:
        yield
    except tuple(exceptions) as e:
        raise cls(exceptions[type(e)] or str(e)) from e


# asynccontextmanager when
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号