diff options
author | Sebastian <sebasjm@gmail.com> | 2023-01-12 15:50:36 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-01-12 15:51:36 -0300 |
commit | 72ca5ee8dda247c1567b5f8d3878cd8371a9983f (patch) | |
tree | 7f24bff10161ec772bca1cb604530c4af87662fe /packages/taler-wallet-core/src | |
parent | 473cbc3908d6f18511fed14fb45af18f3cd1ee32 (diff) | |
download | wallet-core-72ca5ee8dda247c1567b5f8d3878cd8371a9983f.tar.xz |
more information if migration failed, and pretty
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r-- | packages/taler-wallet-core/src/db.ts | 32 | ||||
-rw-r--r-- | packages/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 index d929fd123..9ca88d086 100644 --- 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 index 2570a4e5f..43ee97239 100644 --- 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: |