Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/pandas/util/_exceptions.py : 29%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import contextlib
2from typing import Tuple
5@contextlib.contextmanager
6def rewrite_exception(old_name: str, new_name: str):
7 """
8 Rewrite the message of an exception.
9 """
10 try:
11 yield
12 except Exception as err:
13 msg = err.args[0]
14 msg = msg.replace(old_name, new_name)
15 args: Tuple[str, ...] = (msg,)
16 if len(err.args) > 1:
17 args = args + err.args[1:]
18 err.args = args
19 raise