Fix handling of sqlite out of memory errors
The "error_code == -1" check never passed, as error_code (confusingly) is a string of a number.
This commit is contained in:
parent
c8b447daec
commit
c2a072f9fe
@ -35,6 +35,7 @@ class SqliteErrorCode:
|
||||
in qutebrowser here.
|
||||
"""
|
||||
|
||||
UNKNOWN = '-1'
|
||||
BUSY = '5' # database is locked
|
||||
READONLY = '8' # attempt to write a readonly database
|
||||
IOERR = '10' # disk I/O error
|
||||
@ -114,7 +115,8 @@ def raise_sqlite_error(msg, error):
|
||||
]
|
||||
|
||||
if (error_code in environmental_errors or
|
||||
(error_code == -1 and database_text in environmental_strings)):
|
||||
(error_code == SqliteErrorCode.UNKNOWN and
|
||||
database_text in environmental_strings)):
|
||||
raise SqlEnvironmentError(msg, error)
|
||||
else:
|
||||
raise SqlBugError(msg, error)
|
||||
|
@ -49,6 +49,15 @@ class TestSqlError:
|
||||
with pytest.raises(exception):
|
||||
sql.raise_sqlite_error("Message", sql_err)
|
||||
|
||||
def test_out_of_memory(self):
|
||||
"""On out of memory error, we get an error code '-1' from Qt."""
|
||||
sql_err = QSqlError("driver text",
|
||||
"out of memory",
|
||||
QSqlError.UnknownError,
|
||||
sql.SqliteErrorCode.UNKNOWN)
|
||||
with pytest.raises(sql.SqlEnvironmentError):
|
||||
sql.raise_sqlite_error("Message", sql_err)
|
||||
|
||||
def test_logging(self, caplog):
|
||||
sql_err = QSqlError("driver text", "db text", QSqlError.UnknownError,
|
||||
'23')
|
||||
|
Loading…
Reference in New Issue
Block a user