From 3fd04ad642f42439a24c1693c0b90f9c05e86d37 Mon Sep 17 00:00:00 2001 From: Mary011196 Date: Fri, 14 Apr 2017 09:28:13 +0300 Subject: [PATCH] adding AccessFileError as new class error excpetion --- beets/dbcore/db.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/beets/dbcore/db.py b/beets/dbcore/db.py index 6b0ed8b43..89b7bd17b 100755 --- a/beets/dbcore/db.py +++ b/beets/dbcore/db.py @@ -32,6 +32,10 @@ from beets.dbcore import types from .query import MatchQuery, NullSort, TrueQuery import six +class AccessFileError(Exception): + """UI exception. Commands should throw this in order to display + nonrecoverable errors to the user. + """ class FormattedMapping(collections.Mapping): """A `dict`-like formatted view of a model. @@ -680,8 +684,11 @@ class Transaction(object): """Execute an SQL statement with substitution values and return the row ID of the last affected row. """ - cursor = self.db._connection().execute(statement, subvals) - return cursor.lastrowid + + cursor = self.db._connection().execute(statement, subvals) + raise AccessFileError("unable to open database file. It might be a permissions problem") + return cursor.lastrowid + def script(self, statements): """Execute a string containing multiple SQL statements."""