use different exit codes for every error circumstance

This commit is contained in:
jesopo 2019-10-25 14:13:48 +01:00
parent 869e91fc2a
commit 0f0924281c

View file

@ -86,7 +86,7 @@ log.info("Starting BitBot %s (Python v%s, db %s)",
lock_file = LockFile.LockFile(lock_location) lock_file = LockFile.LockFile(lock_location)
if not lock_file.available(): if not lock_file.available():
log.critical("Database is locked. Is BitBot already running?") log.critical("Database is locked. Is BitBot already running?")
sys.exit(1) sys.exit(2)
atexit.register(lock_file.unlock) atexit.register(lock_file.unlock)
lock_file.lock() lock_file.lock()
@ -159,13 +159,13 @@ if len(server_configs):
if not bot.connect(server): if not bot.connect(server):
log.error("Failed to connect to '%s'" % str(server)) log.error("Failed to connect to '%s'" % str(server))
if not args.startup_disconnects: if not args.startup_disconnects:
sys.exit(1) sys.exit(3)
try: try:
bot.run() bot.run()
except Exception as e: except Exception as e:
log.critical("Unhandled exception: %s", [str(e)], exc_info=True) log.critical("Unhandled exception: %s", [str(e)], exc_info=True)
sys.exit(1) sys.exit(4)
else: else:
try: try:
if utils.cli.bool_input("no servers found, add one?"): if utils.cli.bool_input("no servers found, add one?"):