summaryrefslogtreecommitdiff
path: root/coverage/collector.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-11-13 19:23:24 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-11-14 11:41:23 -0500
commit1c29ef3e4b871508bb2defd6b47b9a745547b626 (patch)
tree931fd2d7175321fd1549fd32e378cddcc99d2537 /coverage/collector.py
parent342e7da2941ae5291f1a94b6ad66ce489f6985fe (diff)
downloadpython-coveragepy-git-1c29ef3e4b871508bb2defd6b47b9a745547b626.tar.gz
refactor: specialize exceptions
CoverageException is fine as a base class, but not good to use for raising (and catching sometimes). Introduce specialized exceptions that allow third-party tools to integrate better.
Diffstat (limited to 'coverage/collector.py')
-rw-r--r--coverage/collector.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/coverage/collector.py b/coverage/collector.py
index 6f9aa2c1..89ba66ba 100644
--- a/coverage/collector.py
+++ b/coverage/collector.py
@@ -9,7 +9,7 @@ import sys
from coverage import env
from coverage.debug import short_stack
from coverage.disposition import FileDisposition
-from coverage.exceptions import CoverageException
+from coverage.exceptions import ConfigError
from coverage.misc import human_sorted, isolate_module
from coverage.pytracer import PyTracer
@@ -116,7 +116,7 @@ class Collector:
# We can handle a few concurrency options here, but only one at a time.
these_concurrencies = self.SUPPORTED_CONCURRENCIES.intersection(concurrency)
if len(these_concurrencies) > 1:
- raise CoverageException(f"Conflicting concurrency settings: {concurrency}")
+ raise ConfigError(f"Conflicting concurrency settings: {concurrency}")
self.concurrency = these_concurrencies.pop() if these_concurrencies else ''
try:
@@ -136,9 +136,9 @@ class Collector:
import threading
self.threading = threading
else:
- raise CoverageException(f"Don't understand concurrency={concurrency}")
+ raise ConfigError(f"Don't understand concurrency={concurrency}")
except ImportError as ex:
- raise CoverageException(
+ raise ConfigError(
"Couldn't trace with concurrency={}, the module isn't installed.".format(
self.concurrency,
)
@@ -245,7 +245,7 @@ class Collector:
if hasattr(tracer, 'concur_id_func'):
tracer.concur_id_func = self.concur_id_func
elif self.concur_id_func:
- raise CoverageException(
+ raise ConfigError(
"Can't support concurrency={} with {}, only threads are supported".format(
self.concurrency, self.tracer_name(),
)