diff --git a/pyrimaa/roundrobin.py b/pyrimaa/roundrobin.py index 03137af..aea8fc6 100755 --- a/pyrimaa/roundrobin.py +++ b/pyrimaa/roundrobin.py @@ -42,6 +42,9 @@ log = logging.getLogger("roundrobin") +class ConfigError(Exception): + pass + def run_bot(bot, config, global_options): cmdline = config.get(bot['name'], "cmdline") @@ -108,13 +111,11 @@ class NotSet: config = ConfigParser() if config.read(args.config) != [args.config]: - print("Could not open '%s'" % (args.config, )) - return 1 + raise ConfigError("Could not open '%s'" % (args.config, )) args.ini = config args.bot_sections = set(config.sections()) if "global" not in args.bot_sections: - print("Did not find expected 'global' section in configuration file.") - return 1 + raise ConfigError("Did not find expected 'global' section in configuration file.") args.bot_sections.remove('global') try: @@ -174,7 +175,12 @@ class NotSet: def main(args=None): - cfg = get_config(args) + try: + cfg = get_config(args) + except ConfigError as exc: + print(exc) + return 1 + if cfg.rounds: print("Number of rounds: %d" % (cfg.rounds, )) else: