ResqliteQueryException class

An error caused by a SQL query — malformed SQL, constraint violations, or runtime execution failures.

try {
  await db.execute('INSERT INTO users(id) VALUES (?)', [1]);
} on ResqliteQueryException catch (e) {
  print(e.message);    // "UNIQUE constraint failed: users.id"
  print(e.sql);        // "INSERT INTO users(id) VALUES (?)"
  print(e.sqliteCode); // 19 (SQLITE_CONSTRAINT)
}

The sqliteCode is the raw SQLite result code. Common values:

  • 1 SQLITE_ERROR — generic
  • 5 SQLITE_BUSY — another writer holds the lock
  • 19 SQLITE_CONSTRAINT — a CHECK, UNIQUE, NOT NULL, or FOREIGN KEY constraint failed. Extended codes narrow it: 787 FK, 1555 PK, 2067 UNIQUE, etc.
Inheritance

Constructors

ResqliteQueryException(String message, {required String sql, List<Object?>? parameters, int? sqliteCode})

Properties

hashCode int
The hash code for this object.
no setterinherited
message String
A human-readable description of the error.
finalinherited
parameters List<Object?>?
The bound parameters, if any.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sql String
The SQL statement that caused the error.
final
sqliteCode int?
The SQLite result code (e.g., 19 for SQLITE_CONSTRAINT).
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited