From d3f7a25833c129dcb784f8d6bc87c378d0824fd2 Mon Sep 17 00:00:00 2001 From: "Pradyun S. Gedam" Date: Sun, 14 May 2017 02:42:22 +0530 Subject: [PATCH] Raise Configuration Errors with proper messages --- pip/configuration.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pip/configuration.py b/pip/configuration.py index b27b8bcd8..3bbed0990 100644 --- a/pip/configuration.py +++ b/pip/configuration.py @@ -104,7 +104,10 @@ class Configuration(object): def get_value(self, key): """Get a value from the configuration. """ - return self._dictionary[key] + try: + return self._dictionary[key] + except KeyError: + raise ConfigurationError("No such key - {}".format(key)) def set_value(self, key, value): """Modify a value in the configuration. @@ -130,7 +133,7 @@ class Configuration(object): self._ensure_have_load_only() if key not in self._config[self.load_only]: - raise ConfigurationError(key) + raise ConfigurationError("No such key - {}".format(key)) file, parser = self._get_parser_to_modify()