Re-raise other errors

And re-use the SQLite error string instead of a hand-written one for now.
This commit is contained in:
Adrian Sampson 2017-04-18 10:32:44 -04:00
parent 621427fa63
commit 19e09585d8

View file

@ -693,10 +693,14 @@ class Transaction(object):
cursor = self.db._connection().execute(statement, subvals)
return cursor.lastrowid
except sqlite3.OperationalError as e:
# In two specific cases, SQLite reports an error while accessing
# the underlying database file. We surface these exceptions as
# DBAccessError so the application can abort.
if e.args[0] in ("attempt to write a readonly database",
"unable to open database file"):
raise DBAccessError('Unable to open database file.'
'It might be a permissions problem')
raise DBAccessError(e.args[0])
else:
raise
def script(self, statements):
"""Execute a string containing multiple SQL statements."""