summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshley Whetter <ashley@awhetter.co.uk>2017-09-09 20:53:57 +0100
committerAshley Whetter <ashley@awhetter.co.uk>2019-02-09 13:23:21 -0800
commit203dd94696199d54fdafe66ad8311fc648aa2ee8 (patch)
tree658f505b9d8a05b14de640f777c60cbfece3e68f
parentdb37ffa33f13d678c5b6c8a1b7172b493a3947c7 (diff)
downloadpylint-git-203dd94696199d54fdafe66ad8311fc648aa2ee8.tar.gz
Started using more specific exceptions in config
-rw-r--r--pylint/config.py12
-rw-r--r--pylint/exceptions.py4
2 files changed, 8 insertions, 8 deletions
diff --git a/pylint/config.py b/pylint/config.py
index 3826704ae..385dda352 100644
--- a/pylint/config.py
+++ b/pylint/config.py
@@ -50,7 +50,7 @@ import time
import configparser
-from pylint import utils
+from pylint import exceptions, utils
USER_HOME = os.path.expanduser("~")
@@ -726,8 +726,7 @@ class Configuration(object):
def add_option(self, option_definition):
name, definition = option_definition
if name in self._option_definitions:
- # TODO: Raise something more sensible
- raise Exception('Option "{0}" already exists.')
+ raise exceptions.ConfigurationError('Option "{0}" already exists.')
self._option_definitions[name] = definition
def add_options(self, option_definitions):
@@ -926,8 +925,7 @@ class CLIParser(ConfigParser):
if "choices" not in definition:
msg = 'No choice list given for option "{0}" of type "choice".'
msg = msg.format(option)
- # TODO: Raise something more sensible
- raise Exception(msg)
+ raise ConfigurationError(msg)
if definition["type"] == "multiple_choice":
kwargs["type"] = VALIDATORS["csv"]
@@ -935,8 +933,7 @@ class CLIParser(ConfigParser):
kwargs["choices"] = definition["choices"]
else:
msg = 'Unsupported type "{0}"'.format(definition["type"])
- # TODO: Raise something more sensible
- raise Exception(msg)
+ raise ConfigurationError(msg)
if definition.get("hide"):
kwargs["help"] = argparse.SUPPRESS
@@ -995,7 +992,6 @@ class IniFileParser(FileParser):
else:
self._option_groups.add(group)
- # TODO: Do we need to do this?
self._parser["DEFAULT"].update(default)
@staticmethod
diff --git a/pylint/exceptions.py b/pylint/exceptions.py
index 57353a466..30640093f 100644
--- a/pylint/exceptions.py
+++ b/pylint/exceptions.py
@@ -23,3 +23,7 @@ class EmptyReportError(Exception):
class InvalidReporterError(Exception):
"""raised when selected reporter is invalid (e.g. not found)"""
+
+
+class ConfigurationError(Exception):
+ """Raised when the configuration is invalid."""