From 7ef29cf551ae0eb87b118943ced7c0d105b2c979 Mon Sep 17 00:00:00 2001 From: Fuxino Date: Thu, 8 Oct 2026 18:06:33 +0200 Subject: [PATCH] Report invalid config files instead of crashing Invalid values (e.g. an empty or non-numeric 'keep') and syntax errors in the config file raised uncaught exceptions. Catch them and exit with code 6, including the reason in the error message. --- simple_backup/simple_backup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/simple_backup/simple_backup.py b/simple_backup/simple_backup.py index 749e148..d9d4a39 100755 --- a/simple_backup/simple_backup.py +++ b/simple_backup/simple_backup.py @@ -922,8 +922,9 @@ def simple_backup() -> int: try: config_args = _read_config(config_file, user) - except (configparser.NoSectionError, configparser.NoOptionError): - logger.critical('Bad configuration file') + except (configparser.Error, ValueError) as e: + # configparser.Error: missing sections/options or bad syntax, ValueError: invalid values (e.g. keep=abc) + logger.critical('Bad configuration file: %s', e) return 6