improve error reporting for DB queries
This commit is contained in:
parent
2c52046f0b
commit
2ec6799c8c
@ -218,7 +218,7 @@ class ResultStream<T> {
|
|||||||
return { hasValue: false };
|
return { hasValue: false };
|
||||||
}
|
}
|
||||||
if (!this.awaitingResult) {
|
if (!this.awaitingResult) {
|
||||||
const cursor = this.req.result;
|
const cursor: IDBCursor | undefined = this.req.result;
|
||||||
if (!cursor) {
|
if (!cursor) {
|
||||||
throw Error("assertion failed");
|
throw Error("assertion failed");
|
||||||
}
|
}
|
||||||
@ -330,7 +330,7 @@ function runWithTransaction<T>(
|
|||||||
reject(TransactionAbort);
|
reject(TransactionAbort);
|
||||||
};
|
};
|
||||||
const th = new TransactionHandle(tx);
|
const th = new TransactionHandle(tx);
|
||||||
const resP = f(th);
|
const resP = Promise.resolve().then(() => f(th));
|
||||||
resP
|
resP
|
||||||
.then(result => {
|
.then(result => {
|
||||||
gotFunResult = true;
|
gotFunResult = true;
|
||||||
@ -340,10 +340,12 @@ function runWithTransaction<T>(
|
|||||||
if (e == TransactionAbort) {
|
if (e == TransactionAbort) {
|
||||||
console.info("aborting transaction");
|
console.info("aborting transaction");
|
||||||
} else {
|
} else {
|
||||||
tx.abort();
|
|
||||||
console.error("Transaction failed:", e);
|
console.error("Transaction failed:", e);
|
||||||
console.error(stack);
|
console.error(stack);
|
||||||
|
tx.abort();
|
||||||
}
|
}
|
||||||
|
}).catch((e) => {
|
||||||
|
console.error("fatal: aborting transaction failed", e);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user