Re-raise other errors
And re-use the SQLite error string instead of a hand-written one for now.
@@ -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."""
