taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 2ec6799c8c6836d44944460a41fabefb8eb8186f
parent 2c52046f0bf358a5e07c53394b3b72d091356cce
Author: Florian Dold <florian.dold@gmail.com>
Date:   Thu, 12 Mar 2020 13:22:46 +0530

improve error reporting for DB queries

Diffstat:
Msrc/util/query.ts | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git 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); }); }); }