From 2ec6799c8c6836d44944460a41fabefb8eb8186f Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 12 Mar 2020 13:22:46 +0530 Subject: improve error reporting for DB queries --- src/util/query.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') 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 { 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( 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( 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); }); }); } -- cgit v1.2.3