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
...@@ -52,8 +52,14 @@ class SimpleConfigReader(object): ...@@ -52,8 +52,14 @@ class SimpleConfigReader(object):
""" """
self._file_name = file_name self._file_name = file_name
self._config_data = serializer.Load(utils.ReadFile(file_name)) try:
# TODO: Error handling 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): def GetClusterName(self):
return self._config_data["cluster"]["cluster_name"] return self._config_data["cluster"]["cluster_name"]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment