From 5313297fe84c596f9222a4890dd45a53a6d4d632 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 20 Jul 2021 06:54:22 -0400 Subject: 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." --- coverage/sqldata.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'coverage/sqldata.py') diff --git a/coverage/sqldata.py b/coverage/sqldata.py index 41542969..b2133026 100644 --- a/coverage/sqldata.py +++ b/coverage/sqldata.py @@ -291,7 +291,7 @@ class CoverageData(SimpleReprMixin): "Data file {!r} doesn't seem to be a coverage data file: {}".format( self._filename, exc ) - ) + ) from exc else: if schema_version != SCHEMA_VERSION: raise CoverageException( @@ -1095,7 +1095,7 @@ class SqliteDb(SimpleReprMixin): pass if self.debug: self.debug.write(f"EXCEPTION from execute: {msg}") - raise CoverageException(f"Couldn't use data file {self.filename!r}: {msg}") + raise CoverageException(f"Couldn't use data file {self.filename!r}: {msg}") from exc def execute_one(self, sql, parameters=()): """Execute a statement and return the one row that results. -- cgit v1.2.1