exceptions: use semantic exceptions (#3430)

This commit is contained in:
Saugat Pachhai
2020-03-16 19:39:59 +02:00
committed by GitHub
parent 066ccea733
commit 1b21789444
3 changed files with 10 additions and 3 deletions
+4
View File
@@ -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."""
+2 -1
View File
@@ -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)
+4 -2
View File
@@ -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: