summaryrefslogtreecommitdiff
path: root/coverage/data.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/data.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/data.py')
-rw-r--r--coverage/data.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/coverage/data.py b/coverage/data.py
index e7c94b4f..c70993ad 100644
--- a/coverage/data.py
+++ b/coverage/data.py
@@ -13,7 +13,7 @@ imports working.
import glob
import os.path
-from coverage.exceptions import CoverageException
+from coverage.exceptions import CoverageException, NoDataError
from coverage.misc import file_be_gone
from coverage.sqldata import CoverageData
@@ -72,7 +72,7 @@ def combinable_files(data_file, data_paths=None):
pattern = os.path.join(os.path.abspath(p), f"{local}.*")
files_to_combine.extend(glob.glob(pattern))
else:
- raise CoverageException(f"Couldn't combine from non-existent path '{p}'")
+ raise NoDataError(f"Couldn't combine from non-existent path '{p}'")
return files_to_combine
@@ -107,7 +107,7 @@ def combine_parallel_data(
files_to_combine = combinable_files(data.base_filename(), data_paths)
if strict and not files_to_combine:
- raise CoverageException("No data to combine")
+ raise NoDataError("No data to combine")
files_combined = 0
for f in files_to_combine:
@@ -138,4 +138,4 @@ def combine_parallel_data(
file_be_gone(f)
if strict and not files_combined:
- raise CoverageException("No usable data files")
+ raise NoDataError("No usable data files")