diff --git a/src/calibre/srv/users.py b/src/calibre/srv/users.py index 86e6b7a48f..42a3d57c36 100644 --- a/src/calibre/srv/users.py +++ b/src/calibre/srv/users.py @@ -76,8 +76,14 @@ def connect(path, exc_class=ValueError): pdir = os.path.dirname(path) if os.path.isdir(pdir): raise exc_class('Failed to open userdb database at {} with error: {}'.format(path, as_unicode(e))) - os.makedirs(pdir) - return apsw.Connection(path) + try: + os.makedirs(pdir) + except EnvironmentError as e: + raise exc_class('Failed to make directory for userdb database at {} with error: {}'.format(pdir, as_unicode(e))) + try: + return apsw.Connection(path) + except apsw.CantOpenError as e: + raise exc_class('Failed to open userdb database at {} with error: {}'.format(path, as_unicode(e))) class UserManager(object):