handlinig AccessFileError in main
@@ -41,6 +41,7 @@ from beets import config
from beets.util import confit, as_string
from beets.autotag import mb
from beets.dbcore import query as db_query
+from beets.dbcore import db
import six
# On Windows platforms, use colorama to support "ANSI" terminal colors.
@@ -1159,13 +1160,10 @@ def _open_library(config):
)
lib.get_item(0) # Test database connection.
except (sqlite3.OperationalError, sqlite3.DatabaseError):
- message = ""
log.debug(u'{}', traceback.format_exc())
- if e.args[0] == "unable to open database file":
- message = "It might be a permissions problem."
- raise UserError(u"database file {0} could not be opened.%s".format(
+ raise UserError(u"database file {0} could not be opened".format(
util.displayable_path(dbpath)
- )%message)
+ ))
log.debug(u'library database: {0}\n'
u'library directory: {1}',
util.displayable_path(lib.path),
@@ -1250,3 +1248,6 @@ def main(args=None):
except KeyboardInterrupt:
# Silently ignore ^C except in verbose mode.
log.debug(u'{}', traceback.format_exc())
+ except db.AccessFileError as exc:
+ log.error(u'{0}',exc)
+ sys.exit(1)
