Nicer error message

This commit is contained in:
Kovid Goyal 2012-11-18 21:51:37 +05:30
parent c412eadeb0
commit 5e4f2aa6ac

View File

@ -320,15 +320,23 @@ class ChooseLibraryAction(InterfaceAction):
_('Path to library too long. Must be less than' _('Path to library too long. Must be less than'
' %d characters.')%LibraryDatabase2.WINDOWS_LIBRARY_PATH_LIMIT, ' %d characters.')%LibraryDatabase2.WINDOWS_LIBRARY_PATH_LIMIT,
show=True) show=True)
if not os.path.exists(loc):
error_dialog(self.gui, _('Not found'),
_('Cannot rename as no library was found at %s. '
'Try switching to this library first, then switch back '
'and retry the renaming.')%loc, show=True)
return
try: try:
os.rename(loc, newloc) os.rename(loc, newloc)
except: except:
import traceback import traceback
det_msg = 'Location: %r New Location: %r\n%s'%(loc, newloc,
traceback.format_exc())
error_dialog(self.gui, _('Rename failed'), error_dialog(self.gui, _('Rename failed'),
_('Failed to rename the library at %s. ' _('Failed to rename the library at %s. '
'The most common cause for this is if one of the files' 'The most common cause for this is if one of the files'
' in the library is open in another program.') % loc, ' in the library is open in another program.') % loc,
det_msg=traceback.format_exc(), show=True) det_msg=det_msg, show=True)
return return
self.stats.rename(location, newloc) self.stats.rename(location, newloc)
self.build_menus() self.build_menus()