aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-03-12 13:22:46 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-03-12 13:23:24 +0530
commit2ec6799c8c6836d44944460a41fabefb8eb8186f (patch)
tree1e4a557435a84c075843737920f2d44eb0330b44 /src
parent2c52046f0bf358a5e07c53394b3b72d091356cce (diff)
improve error reporting for DB queries
Diffstat (limited to 'src')
-rw-r--r--src/util/query.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/util/query.ts b/src/util/query.ts
index d08c901a4..3303907fe 100644
--- a/src/util/query.ts
+++ b/src/util/query.ts
@@ -218,7 +218,7 @@ class ResultStream<T> {
return { hasValue: false };
}
if (!this.awaitingResult) {
- const cursor = this.req.result;
+ const cursor: IDBCursor | undefined = this.req.result;
if (!cursor) {
throw Error("assertion failed");
}
@@ -330,7 +330,7 @@ function runWithTransaction<T>(
reject(TransactionAbort);
};
const th = new TransactionHandle(tx);
- const resP = f(th);
+ const resP = Promise.resolve().then(() => f(th));
resP
.then(result => {
gotFunResult = true;
@@ -340,10 +340,12 @@ function runWithTransaction<T>(
if (e == TransactionAbort) {
console.info("aborting transaction");
} else {
- tx.abort();
console.error("Transaction failed:", e);
console.error(stack);
+ tx.abort();
}
+ }).catch((e) => {
+ console.error("fatal: aborting transaction failed", e);
});
});
}