From a19278da659daa89e170d9fe017eda4e18318b82 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 21 Nov 2017 11:54:59 -0800 Subject: [PATCH] Handle configparser errors more gracefully. --- zulip_bots/zulip_bots/lib.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/zulip_bots/zulip_bots/lib.py b/zulip_bots/zulip_bots/lib.py index f845686..b8550e5 100644 --- a/zulip_bots/zulip_bots/lib.py +++ b/zulip_bots/zulip_bots/lib.py @@ -218,7 +218,14 @@ def run_message_handler_for_bot(lib_module, quiet, config_file, bot_name): # Make sure you set up your ~/.zuliprc client_name = "Zulip{}Bot".format(bot_name.capitalize()) - client = Client(config_file=config_file, client=client_name) + + try: + 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__) restricted_client = ExternalBotHandler(client, bot_dir, bot_details)