summaryrefslogtreecommitdiff
path: root/dotbot
diff options
context:
space:
mode:
authorAnish Athalye <me@anishathalye.com>2014-07-17 10:02:53 -0700
committerAnish Athalye <me@anishathalye.com>2014-07-17 13:40:08 -0700
commit5394184d14b0acb714a32f26d3d60ed5b4fbb3c0 (patch)
treefe4cae81178d6dc7fa95b38fef27f7e4295b02dc /dotbot
parenta97096ef962f64d98d70e92ec21f9edb4842985a (diff)
Display better error message when linking fails
When failing to symbolically linking files, display the names of the files that could not be linked. This makes it easier to troubleshoot the error without having to manually figure out which files failed to link.
Diffstat (limited to 'dotbot')
-rw-r--r--dotbot/executor/linker.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/dotbot/executor/linker.py b/dotbot/executor/linker.py
index 0e25838..bd0b909 100644
--- a/dotbot/executor/linker.py
+++ b/dotbot/executor/linker.py
@@ -60,9 +60,13 @@ class Linker(Executor):
self._log.warning('Invalid link %s -> %s' %
(link_name, self._link_destination(link_name)))
elif not self._exists(link_name) and self._exists(source):
- self._log.lowinfo('Creating link %s -> %s' % (link_name, source))
- os.symlink(source, os.path.expanduser(link_name))
- success = True
+ try:
+ os.symlink(source, os.path.expanduser(link_name))
+ except OSError as e:
+ self._log.warning('Linking failed %s -> %s' % (link_name, source))
+ else:
+ self._log.lowinfo('Creating link %s -> %s' % (link_name, source))
+ success = True
elif self._exists(link_name) and not self._is_link(link_name):
self._log.warning(
'%s already exists but is a regular file or directory' %