From b415ae9a21a93a93f456f0de50b0e91d37eca344 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Mon, 22 Oct 2018 22:43:51 +0300 Subject: [PATCH] system: catch link exceptions Signed-off-by: Ruslan Kuprieiev --- dvc/system.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dvc/system.py b/dvc/system.py index 7801f8c63..b54cc2471 100644 --- a/dvc/system.py +++ b/dvc/system.py @@ -12,8 +12,11 @@ class System(object): from dvc.exceptions import DvcException if System.is_unix(): - os.link(source, link_name) - return + try: + os.link(source, link_name) + return + except Exception as exc: + raise DvcException('link', cause=exc) CreateHardLink = ctypes.windll.kernel32.CreateHardLinkW CreateHardLink.argtypes = [ctypes.c_wchar_p, @@ -31,7 +34,11 @@ class System(object): from dvc.exceptions import DvcException if System.is_unix(): - return os.symlink(source, link_name) + try: + os.symlink(source, link_name) + return + except Exception as exc: + raise DvcException('symlink', cause=exc) flags = 0 if source is not None and os.path.isdir(source):