summaryrefslogtreecommitdiff
path: root/coverage/control.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 08:12:49 -0500
commitb82e9fd8766a77c2a275bde7b574f3e8cb529f8f (patch)
treef310ea38a19f2b4e8c93ee3e3a5b8a99aa43351a /coverage/control.py
parent342e7da2941ae5291f1a94b6ad66ce489f6985fe (diff)
downloadpython-coveragepy-git-b82e9fd8766a77c2a275bde7b574f3e8cb529f8f.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/control.py')
-rw-r--r--coverage/control.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/coverage/control.py b/coverage/control.py
index 47e741aa..c80a74f5 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -21,7 +21,7 @@ from coverage.context import should_start_context_test_function, combine_context
from coverage.data import CoverageData, combine_parallel_data
from coverage.debug import DebugControl, short_stack, write_formatted_info
from coverage.disposition import disposition_debug_msg
-from coverage.exceptions import CoverageException, CoverageWarning
+from coverage.exceptions import ConfigError, CoverageException, CoverageWarning, PluginError
from coverage.files import PathAliases, abs_file, relative_filename, set_relative_directory
from coverage.html import HtmlReporter
from coverage.inorout import InOrOut
@@ -449,7 +449,7 @@ class Coverage:
concurrency = self.config.concurrency or ()
if "multiprocessing" in concurrency:
if not patch_multiprocessing:
- raise CoverageException( # pragma: only jython
+ raise ConfigError( # pragma: only jython
"multiprocessing is not supported on this Python"
)
patch_multiprocessing(rcfile=self.config.config_file)
@@ -460,7 +460,7 @@ class Coverage:
elif dycon == "test_function":
context_switchers = [should_start_context_test_function]
else:
- raise CoverageException(f"Don't understand dynamic_context setting: {dycon!r}")
+ raise ConfigError(f"Don't understand dynamic_context setting: {dycon!r}")
context_switchers.extend(
plugin.dynamic_context for plugin in self._plugins.context_switchers
@@ -835,7 +835,7 @@ class Coverage:
if plugin:
file_reporter = plugin.file_reporter(mapped_morf)
if file_reporter is None:
- raise CoverageException(
+ raise PluginError(
"Plugin {!r} did not provide a file reporter for {!r}.".format(
plugin._coverage_plugin_name, morf
)