Jul-13-2019, 09:41 PM
1/0
Error:Traceback (most recent call last):
File "C:/Documents/err.py", line 9, in <module>
1/0
ZeroDivisionError: division by zeroI 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.Error:Traceback (most recent call last):
File "C:/Documents/err.py", line 10, in <module>
1/0
ZeroDivisionError: division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Documents/err.py", line 12, in <module>
raise ZeroDivisionError("Don't do that")
ZeroDivisionError: Don't do thatI imagine the answer is in the traceback module but I cannot find it.What I want is:
Error:Traceback (most recent call last):
File "C:/Documents/err.py", line 9, in <module>
1/0
ZeroDivisionError: Don't do that
