diff --git a/dvc/exceptions.py b/dvc/exceptions.py index 2a1b1cc5d..0a09cb5e2 100644 --- a/dvc/exceptions.py +++ b/dvc/exceptions.py @@ -325,3 +325,7 @@ class RemoteCacheRequiredError(DvcException): format_link("https://man.dvc.org/config#cache"), ) ) + + +class IsADirectoryError(DvcException): + """Raised when a file operation is requested on a directory.""" diff --git a/dvc/repo/__init__.py b/dvc/repo/__init__.py index 9fb3f5ee1..e7db95646 100644 --- a/dvc/repo/__init__.py +++ b/dvc/repo/__init__.py @@ -10,6 +10,7 @@ from funcy import cached_property, cat, first from dvc.config import Config from dvc.exceptions import ( FileMissingError, + IsADirectoryError, NotDvcRepoError, OutputNotFoundError, ) @@ -476,7 +477,7 @@ class Repo(object): def _open_cached(self, out, remote=None, mode="r", encoding=None): if out.isdir(): - raise ValueError("Can't open a dir") + raise IsADirectoryError("Can't open a dir") cache_file = self.cache.local.checksum_to_path_info(out.checksum) cache_file = fspath_py35(cache_file) diff --git a/dvc/repo/reproduce.py b/dvc/repo/reproduce.py index e8c7d417c..f0c3b96ec 100644 --- a/dvc/repo/reproduce.py +++ b/dvc/repo/reproduce.py @@ -1,6 +1,6 @@ import logging -from dvc.exceptions import ReproductionError +from dvc.exceptions import ReproductionError, InvalidArgumentError from dvc.repo.scm_context import scm_context from . import locked from .graph import get_pipeline, get_pipelines @@ -61,7 +61,9 @@ def reproduce( from dvc.stage import Stage if not target and not all_pipelines: - raise ValueError() + raise InvalidArgumentError( + "Neither target nor all_pipelines are specified." + ) interactive = kwargs.get("interactive", False) if not interactive: