From c44bbcd1d86e6c4192988f20319d9e3c94e263b6 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 27 Nov 2014 07:38:40 -0500 Subject: Give error messages if an explicitly provided rcfile can't be read. --- coverage/config.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'coverage/config.py') diff --git a/coverage/config.py b/coverage/config.py index 9598f74d..65f4222a 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'): -- cgit v1.2.1