try:
...
except Exception as e:
Don't catch Exception at a low level. Catch OSError, which now includes EnvironmentError and IOError. This should cover all the things that can occur for external reasons. If you get some unexpected error such as a SyntaxError or TypeError, for example, that indicates a bug in the program.
At the outermost level, catch Exception, and log a bug with a backtrace if an unhandled exception reaches that level.An exception is not an error code.