Better error handling in the settings loader for entry not found in block

This commit is contained in:
Clemens Schwaighofer
2025-07-14 16:49:37 +09:00
parent aa2fbd4f70
commit 0770ac0bb4
3 changed files with 10 additions and 2 deletions

View File

@@ -94,6 +94,13 @@ class SettingsLoader:
try:
# load all data as is, validation is done afterwards
settings[config_id] = dict(self.config_parser[config_id])
except KeyError as e:
self.__print(
f"[!] Cannot read [{config_id}] block in the {self.config_file}: {e}",
'CRITICAL', raise_exception=True
)
sys.exit(1)
try:
for key, checks in config_validate.items():
skip = True
split_char = self.DEFAULT_ELEMENT_SPLIT_CHAR
@@ -145,7 +152,7 @@ class SettingsLoader:
]
except KeyError as e:
self.__print(
f"[!] Cannot read [{config_id}] block in the {self.config_file}: {e}",
f"[!] Cannot read [{config_id}] block because the entry [{e}] could not be found",
'CRITICAL', raise_exception=True
)
sys.exit(1)