Reputation: 864
I am new to python and I have been wondering if you can do something like this in python.
try:
something():
if it throws an exception then try this:
something1():
if it throws an exception again:
print(exception)
Upvotes: 1
Views: 77
Reputation: 16743
Of course you can.
try:
something()
except Exception as exp:
try:
something1()
except Exception as exp2:
print(exp, exp2)
raise exp # in case you want to raise the original exception
Upvotes: 1