2021-02-18 05:04:59 +03:00
|
|
|
def doTheThing(excp):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
raise excp
|
2023-11-25 05:11:56 +03:00
|
|
|
except (TypeError, ValueError) as exception:
|
2021-02-18 05:04:59 +03:00
|
|
|
print("Caught a", repr(exception))
|
|
|
|
for i in exception.traceback:
|
|
|
|
let func, instr = i
|
|
|
|
print(f" File '{func.__file__}', line {func._ip_to_line(instr)}, in {func.__name__}")
|
|
|
|
except NameError:
|
|
|
|
print("That's a name error!")
|
|
|
|
|
|
|
|
|
|
|
|
doTheThing(TypeError("A type error"))
|
|
|
|
doTheThing(ValueError("A value error"))
|
|
|
|
doTheThing(NameError("A name error"))
|
|
|
|
|