             // Special case: Write additional info to the database log in the case of a database corruption.
             if error.code == Int(SQLITE_CORRUPT) {
                 writeCorruptionInfoForDBNamed(filename, toLogger: Logger.corruptLogger)
-            }
-
-            log.error("SQL error: \(error.localizedDescription).")
+                
+                SentryIntegration.shared.sendWithStacktrace(message: "SQLITE_CORRUPT for DB \(filename), \(error)", tag: "SwiftData", severity: .error)
+            }
+
+            log.error("SQL error. Error code: \(error.code), \(error) for SQL \(sqlStr).")
+            SentryIntegration.shared.sendWithStacktrace(message: "SQL error. Error code: \(error.code), \(error)", tag: "SwiftData", severity: .error)
+
             return Cursor<T>(err: error)
         }
 

    func transaction(synchronous: Bool=true, transactionClosure: @escaping (_ db: SQLiteDBConnection) -> Bool) -> NSError? {
        return withConnection(SwiftData.Flags.readWriteCreate, synchronous: synchronous) { db in
            if let err = db.executeChange("BEGIN EXCLUSIVE") {
                log.warning("BEGIN EXCLUSIVE failed.")
                return err
            }

            if transactionClosure(db) {
                log.verbose("Op in transaction succeeded. Committing.")
                if let err = db.executeChange("COMMIT") {
                    log.error("COMMIT failed. Rolling back.")
                    let _ = db.executeChange("ROLLBACK")
                    return err
                }
            } else {
                log.debug("Op in transaction failed. Rolling back.")
                if let err = db.executeChange("ROLLBACK") {
                    return err
                }
            }

        } catch let error1 as NSError {
            error = error1
            statement = nil
        }

        // Close, not reset -- this isn't going to be reused.
