From 9635449ac081870c55af25b1139714afc1aa3486 Mon Sep 17 00:00:00 2001 From: Patrick Robertson Date: Tue, 28 Jan 2025 11:44:52 +0100 Subject: [PATCH] more user friendly error logging when config issues are found --- src/auto_archiver/core/config.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/auto_archiver/core/config.py b/src/auto_archiver/core/config.py index 245fdaf..529e1c2 100644 --- a/src/auto_archiver/core/config.py +++ b/src/auto_archiver/core/config.py @@ -33,7 +33,19 @@ logging: # note: 'logging' is explicitly added above in order to better format the config file class DefaultValidatingParser(argparse.ArgumentParser): + + def error(self, message): + """ + Override of error to format a nicer looking error message using logger + """ + logger.error("Problem with configuration file (tip: use --help to see the available options):") + logger.error(message) + self.exit(2) + def parse_known_args(self, args=None, namespace=None): + """ + Override of parse_known_args to also check the 'defaults' values - which are passed in from the config file + """ for action in self._actions: if not namespace or action.dest not in namespace: if action.default is not None: