menu plugin: handle common KConfig errors
This patch handles common Kconfig errors (file not found, invalid config) and reports them as user errors. By that, the root cause of the error is easier to spot by the user. Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
222f07de69
commit
2503ab39cd
@ -70,8 +70,8 @@ import logging
|
||||
import os
|
||||
import pprint
|
||||
import yaml
|
||||
from kconfiglib import Kconfig, Symbol, Choice, expr_value, TYPE_TO_STR, \
|
||||
MENU, COMMENT, STRING, BOOL, INT, HEX, UNKNOWN
|
||||
from kconfiglib import Kconfig, Symbol, Choice, KconfigError, \
|
||||
expr_value, TYPE_TO_STR, MENU, COMMENT, STRING, BOOL, INT, HEX, UNKNOWN
|
||||
from kas import __version__, __file_version__
|
||||
from kas.context import create_global_context
|
||||
from kas.config import CONFIG_YAML_FILE
|
||||
@ -100,6 +100,13 @@ class MissingModuleError(KasUserError):
|
||||
pass
|
||||
|
||||
|
||||
class KConfigLoadError(KasUserError):
|
||||
"""
|
||||
The KConfig file could not be found or is invalid
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def check_sym_is_string(sym):
|
||||
if sym.type != STRING:
|
||||
raise VariableTypeError('Variable {} must be of string type'
|
||||
@ -253,7 +260,10 @@ class Menu:
|
||||
|
||||
ctx = create_global_context(args)
|
||||
|
||||
self.kconf = Kconfig(args.kconfig, warn_to_stderr=False)
|
||||
try:
|
||||
self.kconf = Kconfig(args.kconfig, warn_to_stderr=False)
|
||||
except (KconfigError, FileNotFoundError) as err:
|
||||
raise KConfigLoadError(str(err))
|
||||
|
||||
config_filename = os.path.join(ctx.kas_work_dir, CONFIG_YAML_FILE)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user