includes: wrap missing include file exception

The common case that an include file cannot be found is now wrapped into
a LoadConfigException. By that, the user gets a more meaningful error
message on the console (instead of a stacktrace).

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Felix Moessbauer 2023-05-08 10:17:39 +02:00 committed by Jan Kiszka
parent 27cf5ea897
commit b21a7e1c3b

View File

@ -186,7 +186,11 @@ class IncludeHandler:
missing_repos = []
configs = []
try:
current_config = load_config(filename)
except FileNotFoundError:
raise LoadConfigException('Configuration file not found',
filename)
if not isinstance(current_config, Mapping):
raise IncludeException('Configuration file does not contain a '
'dictionary as base type')