DatabaseError
DatabaseError wraps an SQLite error.
-
The SQLite error code (see https://www.sqlite.org/rescode.html#primary_result_code_list).
do { ... } catch let error as DatabaseError where error.resultCode == .SQL_CONSTRAINT { // A constraint error }
This property returns a “primary result code”, that is to say the least significant 8 bits of any SQLite result code. See https://www.sqlite.org/rescode.html for more information.
See also
extendedResultCode
. -
The SQLite extended error code (see https://www.sqlite.org/rescode.html#extended_result_code_list).
do { ... } catch let error as DatabaseError where error.extendedResultCode == .SQLITE_CONSTRAINT_FOREIGNKEY { // A foreign key constraint error }
See also
resultCode
. -
The SQLite error message.
-
The SQL query that yielded the error (if relevant).
-
The query arguments that yielded the error (if relevant).
-
Creates a DatabaseError.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Returns true if the error has code
SQLITE_ABORT
orSQLITE_INTERRUPT
.Such an error can be thrown when a database has been interrupted, or when the database is suspended.
See
DatabaseReader.interrupt()
andDatabaseReader.suspend()
for more information. -
The error description.
For example:
SQLite error 19: NOT NULL constraint failed: player.score - while executing `UPDATE player SET score = ? WHERE email = ?
The format of the error description may change between GRDB releases, without notice: don’t have your application rely on any specific format.
-
The error description, where bound parameters, if present, are visible.
For example:
SQLite error 19: NOT NULL constraint failed: player.score - while executing `UPDATE player SET score = ? WHERE email = ? with arguments [nil, "arthur@example.com"]
The format of the error description may change between GRDB releases, without notice: don’t have your application rely on any specific format.
Warning
It is your responsibility to prevent sensitive information from leaking in unexpected locations, so use this property with care.