diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-11-13 19:23:24 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-11-14 08:12:49 -0500 |
commit | b82e9fd8766a77c2a275bde7b574f3e8cb529f8f (patch) | |
tree | f310ea38a19f2b4e8c93ee3e3a5b8a99aa43351a /coverage/collector.py | |
parent | 342e7da2941ae5291f1a94b6ad66ce489f6985fe (diff) | |
download | python-coveragepy-git-nedbat/exceptions.tar.gz |
refactor: specialize exceptionsnedbat/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.py | 10 |
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(), ) |