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
评论列表
文章目录