Changing a traceback message without a 2nd raise - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Changing a traceback message without a 2nd raise (/thread-19773.html) |
Changing a traceback message without a 2nd raise - Clunk_Head - Jul-13-2019 1/0 I want to change exactly one thing about this stack trace, that message that follows the colon.I do not want to raise a 2nd Error because I need to preserve the ability to click back through in the shell. I've tried capturing it: try: 1/0 except ZeroDivisionError: raise ZeroDivisionError("Don't do that")But this makes the traceback too complex and the last click back is to the raise, not the actual error. I imagine the answer is in the traceback module but I cannot find it.What I want is:
RE: Changing a traceback message without a 2nd raise - Gribouillis - Jul-14-2019 Try try: 1/0 except ZeroDivisionError as err: err.args = ("Don't do that",) raise |