I have a typical scenario where I have a module like below:
def fun2():
#does something which can throw a ValueError exception
def fun3():
#does something which can throw a ValueError exception
def fun1:
fun2() #call to fun2
fun3() #call to fun3
def fun0:
try:
fun1()
except ValueError as e:
##try to find out from which function ValueError Exception is thrown
print(customErrorMsg)
How can I find out that in the except block of fun0
, error is thrown from fun2
or fun3
? I tried e.__traceback__
but it doesnt give useful output.
Strictly speaking, I want to print different customErrorMsg
when the exception is thrown from fun2
or fun3
.