From b82e9fd8766a77c2a275bde7b574f3e8cb529f8f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 13 Nov 2021 19:23:24 -0500 Subject: 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. --- coverage/exceptions.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'coverage/exceptions.py') diff --git a/coverage/exceptions.py b/coverage/exceptions.py index de2257a1..7352e9fc 100644 --- a/coverage/exceptions.py +++ b/coverage/exceptions.py @@ -14,6 +14,20 @@ class CoverageException(_BaseCoverageException): pass +class ConfigError(_BaseCoverageException): + """A problem with a config file, or a value in one.""" + pass + + +class DataError(CoverageException): + """An error in using a data file.""" + pass + +class NoDataError(CoverageException): + """We didn't have data to work with.""" + pass + + class NoSource(CoverageException): """We couldn't find the source for a module.""" pass @@ -29,6 +43,11 @@ class NotPython(CoverageException): pass +class PluginError(CoverageException): + """A plugin misbehaved.""" + pass + + class _ExceptionDuringRun(CoverageException): """An exception happened while running customer code. -- cgit v1.2.1