diff --git a/dvc/exceptions.py b/dvc/exceptions.py index 1bf79dbc9..6d52b33bf 100644 --- a/dvc/exceptions.py +++ b/dvc/exceptions.py @@ -11,3 +11,9 @@ class DvcException(Exception): except Exception: pass super(DvcException, self).__init__(msg) + + +class UnsupportedRemoteError(DvcException): + def __init__(self, config, cause=None): + msg = "Remote '{}' is not supported.".format(config) + super(UnsupportedRemoteError, self).__init__(msg, cause=cause) diff --git a/dvc/remote/__init__.py b/dvc/remote/__init__.py index a6537c921..7fec8f094 100644 --- a/dvc/remote/__init__.py +++ b/dvc/remote/__init__.py @@ -6,7 +6,7 @@ from dvc.remote.ssh import RemoteSSH from dvc.remote.azure import RemoteAzure from dvc.config import Config -from dvc.exceptions import DvcException +from dvc.exceptions import UnsupportedRemoteError REMOTES = [RemoteHDFS, RemoteSSH, RemoteS3, RemoteGS, RemoteAzure, RemoteLOCAL] @@ -24,4 +24,4 @@ def Remote(project, config): for r in REMOTES: if r.supported(config): return r(project, config) - raise DvcException('Remote \'{}\' is not supported.'.format(config)) + raise UnsupportedRemoteError(str(config)) diff --git a/tests/test_remote.py b/tests/test_remote.py index d8c5c9219..1045d93ad 100644 --- a/tests/test_remote.py +++ b/tests/test_remote.py @@ -1,5 +1,8 @@ from dvc.main import main from dvc.command.remote import CmdRemoteAdd +from dvc.exceptions import UnsupportedRemoteError +from dvc.remote import Remote +from dvc.config import Config from tests.basic_env import TestDvc @@ -34,3 +37,7 @@ class TestRemote(TestDvc): cmd.configobj.write = None ret = cmd.run() self.assertNotEqual(ret, 0) + + def test_unsupported(self): + with self.assertRaises(UnsupportedRemoteError): + Remote(self.dvc, {Config.SECTION_REMOTE_URL: 'unsupported://url')