Skip to content
Snippets Groups Projects
Commit 01cf7dbe authored by Guido Trotter's avatar Guido Trotter
Browse files

SimpleConfigReader: Handle errors when loading


Handling both IOErrors and ValueErrors (thrown by the simplejson loader)

Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 3f71b464
No related branches found
No related tags found
No related merge requests found
......@@ -52,8 +52,14 @@ class SimpleConfigReader(object):
"""
self._file_name = file_name
self._config_data = serializer.Load(utils.ReadFile(file_name))
# TODO: Error handling
try:
self._config_data = serializer.Load(utils.ReadFile(file_name))
except IOError, err:
raise errors.ConfigurationError("Cannot read config file %s: %s" %
(file_name, err))
except ValueError, err:
raise errors.ConfigurationError("Cannot load config file %s: %s" %
(file_name, err))
def GetClusterName(self):
return self._config_data["cluster"]["cluster_name"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment