I know I can catch exceptions in python like:
try:
with open('file.log') as file:
read_data = file.read()
except:
print('Exception!')
But how to get exception type or error message?
try:
with open('file.log') as file:
read_data = file.read()
except Exception as e:
print(e)
You have to cast the Exception to a variable. This and more is in the Python documentation.