I'm reading some source code which contains a function similar to the following:
def dummy_function():
try:
g = 1/0
except Exception as e:
raise Exception("There is an error: {}".format(e))
As I understand it, all exceptions are derived from the Exception class, so this should catch all errors. Following https://docs.python.org/3/tutorial/errors.html, then, would this not be equivalent to
def dummy_function():
try:
g = 1/0
except:
print "There is an error:"
raise
I notice that the printed output is arranged slightly differently in either case, but it would seem to me that the second method is basically the same and less verbose. Or am I missing something?