From 5038964f746f9306aa3fbb38a83cafb146f40069 Mon Sep 17 00:00:00 2001 From: Giovanni La Mura <giovanni.lamura@inaf.it> Date: Thu, 20 Mar 2025 17:20:59 +0100 Subject: [PATCH] Handle unrecognized argument exception in pycompare --- src/scripts/pycompare.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/scripts/pycompare.py b/src/scripts/pycompare.py index 01ea0144..b4b0a0c3 100755 --- a/src/scripts/pycompare.py +++ b/src/scripts/pycompare.py @@ -51,7 +51,13 @@ number_reg = re.compile(r'-?[0-9]\.[0-9]+E?[-+][0-9]{2,5}') # # \returns errors: `int` Number of detected error-level inconsistencies. def main(): - config = parse_arguments() + config = {} + try: + config = parse_arguments() + except ValueError as ex: + print(ex) + print("\nType \"pycompare.py --help\" to get more detailed help.") + exit(1) errors, warnings, noisy = (0, 0, 0) if config['help_mode'] or len(argv) == 1: config['help_mode'] = True @@ -527,7 +533,7 @@ def parse_arguments(): elif (arg.startswith("--warn")): config['warning_threshold'] = float(split_arg[1]) else: - raise Exception("Unrecognized argument \'{0:s}\'".format(arg)) + raise ValueError("Unrecognized argument \'{0:s}\'".format(arg)) arg_index += 1 return config -- GitLab