I was not aware that it was not possible to change primary key in Dexie and it gave me this error:
UpgradeError Not yet support for changing primary key
But my main issue is that this error is silent in useLiveQuery():
useLiveQuery(
() => db.tournaments.limit(5).reverse().toArray(),
[],
"loading",
);
I need to catch this error in every useLiveQuery to throw it again in order for the ErrorBoundary to render an error message so that I can tell the user to delete the entire database manually.
useLiveQuery(
() => {
try{
db.tournaments.limit(5).reverse().toArray()
}catch(e){
throw new Error("DB error")
}
}
[],
"loading",
);
I think this error is caught in dexie.js from line 1274:
Table.prototype._trans = function (mode, fn, writeLocked) {
var trans = this._tx || PSD.trans;
var tableName = this.name;
var task = debug && typeof console !== 'undefined' && console.createTask && console.createTask("Dexie: ".concat(mode === 'readonly' ? 'read' : 'write', " ").concat(this.name));
function checkTableInTransaction(resolve, reject, trans) {
if (!trans.schema[tableName])
throw new exceptions.NotFound("Table " + tableName + " not part of transaction");
return fn(trans.idbtrans, trans);
}
var wasRootExec = beginMicroTickScope();
try {
var p = trans && trans.db._novip === this.db._novip ?
trans === PSD.trans ?
trans._promise(mode, checkTableInTransaction, writeLocked) :
newScope(function () { return trans._promise(mode, checkTableInTransaction, writeLocked); }, { trans: trans, transless: PSD.transless || PSD }) :
tempTransaction(this.db, mode, [this.name], checkTableInTransaction);
if (task) {
p._consoleTask = task;
p = p.catch(function (err) {
console.trace(err); <<<===== HERE
return rejection(err);
});
}
return p;
}
finally {
if (wasRootExec)
endMicroTickScope();
}
};
Is this DatabaseClosedError error supposed to be silent in useLiveQuery()
?