taler-typescript-core

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

commit 72ca5ee8dda247c1567b5f8d3878cd8371a9983f
parent 473cbc3908d6f18511fed14fb45af18f3cd1ee32
Author: Sebastian <sebasjm@gmail.com>
Date:   Thu, 12 Jan 2023 15:50:36 -0300

more information if migration failed, and pretty

Diffstat:
Mpackages/taler-wallet-core/src/db.ts | 32++++++++++++++++++++++++--------
Mpackages/taler-wallet-core/src/operations/transactions.ts | 1-
2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts @@ -21,6 +21,7 @@ import { Event, IDBDatabase, IDBFactory, + IDBObjectStore, IDBTransaction, } from "@gnu-taler/idb-bridge"; import { @@ -2477,20 +2478,35 @@ function upgradeFromStoreMap( if (storeAddedVersion <= oldVersion) { continue; } - const s = db.createObjectStore(swi.storeName, { - autoIncrement: storeDesc.autoIncrement, - keyPath: storeDesc.keyPath, - }); + let s: IDBObjectStore; + try { + s = db.createObjectStore(swi.storeName, { + autoIncrement: storeDesc.autoIncrement, + keyPath: storeDesc.keyPath, + }); + } catch (e) { + const moreInfo = e instanceof Error ? ` Reason: ${e.message}` : ""; + throw Error( + `Migration failed. Could not create store ${swi.storeName}.${moreInfo}`, + ); + } for (const indexName in swi.indexMap as any) { const indexDesc: IndexDescriptor = swi.indexMap[indexName]; const indexAddedVersion = indexDesc.versionAdded ?? 0; if (indexAddedVersion <= oldVersion) { continue; } - s.createIndex(indexDesc.name, indexDesc.keyPath, { - multiEntry: indexDesc.multiEntry, - unique: indexDesc.unique, - }); + try { + s.createIndex(indexDesc.name, indexDesc.keyPath, { + multiEntry: indexDesc.multiEntry, + unique: indexDesc.unique, + }); + } catch (e) { + const moreInfo = e instanceof Error ? ` Reason: ${e.message}` : ""; + throw Error( + `Migration failed. Could not create index ${indexDesc.name}/${indexDesc.keyPath}.${moreInfo}`, + ); + } } } } diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts @@ -734,7 +734,6 @@ async function buildTransactionForPurchase( checkDbInvariant(!!timestamp); checkDbInvariant(!!purchaseRecord.payInfo); - let status: ExtendedStatus; switch (purchaseRecord.purchaseStatus) { case PurchaseStatus.AbortingWithRefund: