8th day of python challenges 111-117
This commit is contained in:
16
venv/lib/python3.6/site-packages/pandas/util/_exceptions.py
Normal file
16
venv/lib/python3.6/site-packages/pandas/util/_exceptions.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import contextlib
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def rewrite_exception(old_name, new_name):
|
||||
"""Rewrite the message of an exception."""
|
||||
try:
|
||||
yield
|
||||
except Exception as e:
|
||||
msg = e.args[0]
|
||||
msg = msg.replace(old_name, new_name)
|
||||
args = (msg,)
|
||||
if len(e.args) > 1:
|
||||
args = args + e.args[1:]
|
||||
e.args = args
|
||||
raise
|
||||
Reference in New Issue
Block a user