diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-11-27 07:38:40 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-11-27 07:38:40 -0500 |
commit | 4b86461bc103745886acd362ebe8db6667e0a67e (patch) | |
tree | 5cdf5f17a7490485a0513df203f57fcc282953a2 /coverage/config.py | |
parent | a9726b43f349b61f172cd5b44c9b255f9bb2c436 (diff) | |
download | python-coveragepy-4b86461bc103745886acd362ebe8db6667e0a67e.tar.gz |
Give error messages if an explicitly provided rcfile can't be read.
Diffstat (limited to 'coverage/config.py')
-rw-r--r-- | coverage/config.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/coverage/config.py b/coverage/config.py index 9598f74..65f4222 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -197,14 +197,24 @@ class CoverageConfig(object): self.attempted_config_files.append(filename) cp = HandyConfigParser(section_prefix) - files_read = cp.read(filename) + try: + files_read = cp.read(filename) + except configparser.Error as err: + raise CoverageException( + "Couldn't read config file %s: %s" % (filename, err) + ) if not files_read: return False self.config_files.extend(files_read) - for option_spec in self.CONFIG_FILE_OPTIONS: - self._set_attr_from_config_option(cp, *option_spec) + try: + for option_spec in self.CONFIG_FILE_OPTIONS: + self._set_attr_from_config_option(cp, *option_spec) + except ValueError as err: + raise CoverageException( + "Couldn't read config file %s: %s" % (filename, err) + ) # [paths] is special if cp.has_section('paths'): |