get: use new exception from public api

This commit is contained in:
Saugat Pachhai
2020-01-16 19:28:14 +05:45
parent fadf60eea6
commit f130e18e2c
2 changed files with 4 additions and 19 deletions
+2 -17
View File
@@ -3,7 +3,7 @@ import logging
from .base import append_doc_link
from .base import CmdBaseNoRepo
from dvc.exceptions import DvcException, NotDvcRepoError
from dvc.exceptions import DvcException
logger = logging.getLogger(__name__)
@@ -18,23 +18,8 @@ class CmdGet(CmdBaseNoRepo):
self.args.path, repo=self.args.url, rev=self.args.rev
)
logger.info(url)
except NotDvcRepoError:
# NOTE: there's no way to get direct links to files inside
# git repository.
logger.exception(
"Could not show url for '{}' from '{}'. ".format(
self.args.path, self.args.url
)
+ "Only DVC repository is supported currently.",
exc_info=None,
)
return 1
except DvcException:
logger.exception(
"failed to show url for '{}' from '{}'".format(
self.args.path, self.args.url
)
)
logger.exception("failed to show url")
return 1
return 0
+2 -2
View File
@@ -203,7 +203,7 @@ def test_get_url_not_existing(tmp_dir, erepo_dir, caplog):
main(["get", fspath(erepo_dir), "not-existing-file", "--show-url"])
== 1
)
assert "failed to show url for 'not-existing-file'" in caplog.text
assert "failed to show url" in caplog.text
def test_get_url_git_only_repo(tmp_dir, scm, caplog):
@@ -211,4 +211,4 @@ def test_get_url_git_only_repo(tmp_dir, scm, caplog):
with caplog.at_level(logging.ERROR):
assert main(["get", fspath(tmp_dir), "foo", "--show-url"]) == 1
assert "Only DVC repository is supported currently" in caplog.text
assert "failed to show url" in caplog.text