summaryrefslogtreecommitdiff
path: root/coverage/collector.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-07-20 06:54:22 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-07-20 05:32:28 -0700
commit5313297fe84c596f9222a4890dd45a53a6d4d632 (patch)
treeceacf73477e129786a8566fff146c18cd57c0edf /coverage/collector.py
parentde38a0e74a8683a3d3381038aeee4d226cc5b714 (diff)
downloadpython-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/collector.py')
-rw-r--r--coverage/collector.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/coverage/collector.py b/coverage/collector.py
index f9e9d14f..73babf44 100644
--- a/coverage/collector.py
+++ b/coverage/collector.py
@@ -137,12 +137,12 @@ class Collector:
self.threading = threading
else:
raise CoverageException(f"Don't understand concurrency={concurrency}")
- except ImportError:
+ except ImportError as ex:
raise CoverageException(
"Couldn't trace with concurrency={}, the module isn't installed.".format(
self.concurrency,
)
- )
+ ) from ex
self.reset()
@@ -318,8 +318,8 @@ class Collector:
(frame, event, arg), lineno = args
try:
fn(frame, event, arg, lineno=lineno)
- except TypeError:
- raise Exception("fullcoverage must be run with the C trace function.")
+ except TypeError as ex:
+ raise Exception("fullcoverage must be run with the C trace function.") from ex
# Install our installation tracer in threading, to jump-start other
# threads.