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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user