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/data.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'coverage/data.py') 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") -- cgit v1.2.1