Display useful error message on web page after get config error
When
When there is an error in the yaml files preventing the config web app or the web portal to show, because static.get_config()
raises an exception. For example because of a duplicated name in config.
What
The web page crash (error 500) with a bad error message "Internal Server Error" with no hint to what the problem is. And you have to dig in the logs to find the reason.
After this MR
Now the web page will display a useful error message telling the reason why the config could not be loaded, so that the user knows what to change.
example:
An error occurred (cannot get beamline configuration)
ValueError: Duplicate key name (dacm1) in config files (motors/wago.yml) and (motors/wago.yml)
Traceback (most recent call last): File "/home/formet/bliss/bliss/config/conductor/web/homepage/homepage_app.py", line 37, in index cfg = static.get_config() File "/home/formet/bliss/bliss/config/static.py", line 211, in get_config CONFIG = Config(base_path, timeout) File "/home/formet/bliss/bliss/config/static.py", line 519, in __init__ self.reload(timeout=timeout) File "/home/formet/bliss/bliss/config/static.py", line 623, in reload self._parse(d, parents) File "/home/formet/bliss/bliss/config/static.py", line 897, in _parse parent[key] = self._parse_list(value, parent) File "/home/formet/bliss/bliss/config/static.py", line 876, in _parse_list self._parse(value, node) File "/home/formet/bliss/bliss/config/static.py", line 897, in _parse parent[key] = self._parse_list(value, parent) File "/home/formet/bliss/bliss/config/static.py", line 877, in _parse_list self._create_index(node) File "/home/formet/bliss/bliss/config/static.py", line 855, in _create_index "(%s) and (%s)" % (name, prev_node.filename, node.filename) ValueError: Duplicate key name (dacm1) in config files (motors/wago.yml) and (motors/wago.yml)