Skip to content

Commit a514216

Browse files
authored
Merge pull request #4098 from theotherjimmy/fail-on-bad-config
Raise error when mbed_app.json is bad
2 parents 8af190f + 1faf44e commit a514216

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tools/config.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ def __init__(self, tgt, top_level_dirs=None, app_config=None):
384384
top_level_dirs may be None (in this case, the constructor will not
385385
search for a configuration file).
386386
"""
387+
config_errors = []
387388
app_config_location = app_config
388389
if app_config_location is None:
389390
for directory in top_level_dirs or []:
@@ -399,8 +400,10 @@ def __init__(self, tgt, top_level_dirs=None, app_config=None):
399400
self.app_config_data = json_file_to_dict(app_config_location) \
400401
if app_config_location else {}
401402
except ValueError as exc:
402-
sys.stderr.write(str(exc) + "\n")
403403
self.app_config_data = {}
404+
config_errors.append(
405+
ConfigException("Could not parse mbed app configuration from %s"
406+
% app_config_location))
404407

405408
# Check the keys in the application configuration data
406409
unknown_keys = set(self.app_config_data.keys()) - \
@@ -433,7 +436,7 @@ def __init__(self, tgt, top_level_dirs=None, app_config=None):
433436

434437
self._process_config_and_overrides(self.app_config_data, {}, "app",
435438
"application")
436-
self.config_errors = None
439+
self.config_errors = config_errors
437440

438441
def add_config_files(self, flist):
439442
"""Add configuration files
@@ -806,6 +809,7 @@ def load_resources(self, resources):
806809
"""
807810
# Update configuration files until added features creates no changes
808811
prev_features = set()
812+
self.validate_config()
809813
while True:
810814
# Add/update the configuration with any .json files found while
811815
# scanning

0 commit comments

Comments
 (0)