Handle configparser errors more gracefully.

This commit is contained in:
Steve Howell 2017-11-21 11:54:59 -08:00
parent e216a29277
commit a19278da65

View file

@ -218,7 +218,14 @@ def run_message_handler_for_bot(lib_module, quiet, config_file, bot_name):
# Make sure you set up your ~/.zuliprc # Make sure you set up your ~/.zuliprc
client_name = "Zulip{}Bot".format(bot_name.capitalize()) client_name = "Zulip{}Bot".format(bot_name.capitalize())
try:
client = Client(config_file=config_file, client=client_name) client = Client(config_file=config_file, client=client_name)
except configparser.Error as e:
file_contents = open(config_file).read()
print('\nERROR: {} seems to be broken:\n\n{}'.format(config_file, file_contents))
print('\nMore details here:\n\n' + str(e) + '\n')
sys.exit(1)
bot_dir = os.path.dirname(lib_module.__file__) bot_dir = os.path.dirname(lib_module.__file__)
restricted_client = ExternalBotHandler(client, bot_dir, bot_details) restricted_client = ExternalBotHandler(client, bot_dir, bot_details)