Error Handling
Exceptions
Raising them
You can raise exceptions with raise
keyword.
raise Exception("Some exception")
raise TypeError("Only integers")
And many other types.
Catching them
Catch them with try
and have multiple except
statements for different exceptions.
try:
...
except Exception as e:
print(repr(e))
except:
...
else:
...
finally:
...
Last updated