diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-07-20 06:54:22 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-07-20 05:32:28 -0700 |
commit | 5313297fe84c596f9222a4890dd45a53a6d4d632 (patch) | |
tree | ceacf73477e129786a8566fff146c18cd57c0edf /coverage/config.py | |
parent | de38a0e74a8683a3d3381038aeee4d226cc5b714 (diff) | |
download | python-coveragepy-git-5313297fe84c596f9222a4890dd45a53a6d4d632.tar.gz |
fix: raise chained errors with "from" #998
This makes exceptions report their causes correctly, as "The above exception was
the direct cause of the following exception" instead of "During handling of the
above exception, another exception occurred."
Diffstat (limited to 'coverage/config.py')
-rw-r--r-- | coverage/config.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/coverage/config.py b/coverage/config.py index 44bae957..7287e963 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -125,7 +125,7 @@ class HandyConfigParser(configparser.RawConfigParser): except re.error as e: raise CoverageException( f"Invalid [{section}].{option} value {value!r}: {e}" - ) + ) from e if value: value_list.append(value) return value_list @@ -272,7 +272,7 @@ class CoverageConfig: try: files_read = cp.read(filename) except (configparser.Error, TomlDecodeError) as err: - raise CoverageException(f"Couldn't read config file {filename}: {err}") + raise CoverageException(f"Couldn't read config file {filename}: {err}") from err if not files_read: return False @@ -285,7 +285,7 @@ class CoverageConfig: if was_set: any_set = True except ValueError as err: - raise CoverageException(f"Couldn't read config file {filename}: {err}") + raise CoverageException(f"Couldn't read config file {filename}: {err}") from err # Check that there are no unrecognized options. all_options = collections.defaultdict(set) |