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.
This commit is contained in:
Fuxino
2026-10-08 18:06:33 +02:00
parent 4f5499eba9
commit 7ef29cf551
+3 -2
View File
@@ -922,8 +922,9 @@ def simple_backup() -> int:
try: try:
config_args = _read_config(config_file, user) config_args = _read_config(config_file, user)
except (configparser.NoSectionError, configparser.NoOptionError): except (configparser.Error, ValueError) as e:
logger.critical('Bad configuration file') # configparser.Error: missing sections/options or bad syntax, ValueError: invalid values (e.g. keep=abc)
logger.critical('Bad configuration file: %s', e)
return 6 return 6