Better json schema loading error message
When json schema file is malformed, it will print following stacktrace:
Traceback (most recent call last):
File "/usr/bin/foris-controller", line 8, in <module>
sys.exit(main())
File "foris-controller/foris_controller/controller/__main__.py", line 229, in main
prepare_app_modules(BaseOpenwrtHandler, [e[0] for e in options.extra_module_path])
File "foris-controller/foris_controller/app.py", line 143, in prepare_app_modules
app_info["validator"] = ForisValidator(schema_dirs, definition_dirs)
File "/usr/lib64/python3.8/site-packages/foris_schema/validator.py", line 215, in __init__
schema = json.load(f)
File "/usr/lib64/python3.8/json/__init__.py", line 293, in load
return loads(fp.read(),
File "/usr/lib64/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python3.8/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 668 column 17 (char 26397)
Meaning that json schema file is malformed, which it isn't really obvious at first glance.
It would be nice to have some error message instead of this stacktrace, for example:
Failed to load json schema 'mymodule.json': json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 668 column 17 (char 26397)
Edited by Martin Matějek