I'm dealing with a set of 3rd party python scripts. I'm noticing this general pattern of enumerating many different Exception classes with no different action taken but logging a string representation of the exception that would be caught.
except AttributeError as ae:
print("Attribute Error while processing the configuration file!\n{0}\n".format( str(ae) ) )
intReturnValue = 1
except IndexError as ie:
print("Index Error while processing the configuration file!\n{0}\n".format( str(ie) ) )
intReturnValue = 1
except NameError as ne:
print("Name Error while processing the configuration file!\n{0}\n".format( str(ne) ) )
intReturnValue = 1
except TypeError as te:
print("Type Error while processing the configuration file!\n{0}\n".format( str(te) ) )
intReturnValue = 1
except:
print("Unexpected error while processing the configuration file!\n{0}\n".format( sys.exc_info()[0] ) )
intReturnValue = 1
Is this pattern some kind of pythonism or more just the author? It seems python allows you to have a general case catch block. Wouldn't it be simpler in this case to just use that and generate the log message a bit more dynamically?