I would put this except higher in the code right after the code which could fail. Then you can exit with the right exit code via `sys.exit()`