I have the code here:
import traceback
try:
raise TypeError("Oups!")
except Exception as err:
try:
raise TypeError("Again !?!")
except:
pass
traceback.print_tb(err.__traceback__)
I am not sure how I could put the error into a variable with the same format. The error looks like:
File "C:/Users/user/PycharmProjects/project/file.py", line 4, in <module>
raise TypeError("Oups!")
Can anyone help?