@@ -68,6 +68,19 @@ class ConfigException(Exception):
68
68
errors"""
69
69
pass
70
70
71
+ class UndefinedParameter (ConfigException ):
72
+ def __init__ (self , param , name , kind , label ):
73
+ self .param = param
74
+ self .name = name
75
+ self .kind = kind
76
+ self .label = label
77
+
78
+ def __str__ (self ):
79
+ return "Attempt to override undefined parameter '{}' in '{}'" .format (
80
+ self .param ,
81
+ ConfigParameter .get_display_name (self .name , self .kind , self .label ),
82
+ )
83
+
71
84
class ConfigParameter (object ):
72
85
"""This class keeps information about a single configuration parameter"""
73
86
@@ -857,13 +870,8 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
857
870
continue
858
871
else :
859
872
self .config_errors .append (
860
- ConfigException (
861
- "Attempt to override undefined parameter" +
862
- (" '%s' in '%s'"
863
- % (full_name ,
864
- ConfigParameter .get_display_name (unit_name ,
865
- unit_kind ,
866
- label )))))
873
+ UndefinedParameter (
874
+ full_name , unit_name , unit_kind , label ))
867
875
868
876
for cumulatives in self .cumulative_overrides .values ():
869
877
cumulatives .update_target (self .target )
@@ -911,10 +919,7 @@ def get_target_config_data(self):
911
919
continue
912
920
if (full_name not in params ) or \
913
921
(params [full_name ].defined_by [7 :] not in rel_names ):
914
- raise ConfigException (
915
- "Attempt to override undefined parameter '%s' in '%s'"
916
- % (name ,
917
- ConfigParameter .get_display_name (tname , "target" )))
922
+ raise UndefinedParameter (name , tname , "target" , "" )
918
923
# Otherwise update the value of the parameter
919
924
params [full_name ].set_value (val , tname , "target" )
920
925
return params
@@ -1050,8 +1055,13 @@ def validate_config(self):
1050
1055
1051
1056
Arguments: None
1052
1057
"""
1053
- if self .config_errors :
1054
- raise self .config_errors [0 ]
1058
+ params , _ = self .get_config_data ()
1059
+ for error in self .config_errors :
1060
+ if (isinstance (error , UndefinedParameter ) and
1061
+ error .param in params ):
1062
+ continue
1063
+ else :
1064
+ raise error
1055
1065
return True
1056
1066
1057
1067
@@ -1071,7 +1081,6 @@ def load_resources(self, resources):
1071
1081
"""
1072
1082
# Update configuration files until added features creates no changes
1073
1083
prev_features = set ()
1074
- self .validate_config ()
1075
1084
while True :
1076
1085
# Add/update the configuration with any .json files found while
1077
1086
# scanning
0 commit comments