From 5394184d14b0acb714a32f26d3d60ed5b4fbb3c0 Mon Sep 17 00:00:00 2001 From: Anish Athalye Date: Thu, 17 Jul 2014 10:02:53 -0700 Subject: [PATCH] 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. --- dotbot/executor/linker.py | 10 +++++++--- 1 file 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' %