From 7b7e3b4565169835ad04062d5c76ba655abd770a Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 10 Jun 2021 10:37:49 +0200 Subject: transaction fixes --- packages/idb-bridge/src/bridge-idb.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'packages/idb-bridge') diff --git a/packages/idb-bridge/src/bridge-idb.ts b/packages/idb-bridge/src/bridge-idb.ts index 58cec8673..ecabfbc7a 100644 --- a/packages/idb-bridge/src/bridge-idb.ts +++ b/packages/idb-bridge/src/bridge-idb.ts @@ -1201,19 +1201,26 @@ export class BridgeIDBIndex implements IDBIndex { private _confirmIndexExists() { const storeSchema = this._schema.objectStores[this._objectStore._name]; if (!storeSchema) { - throw new InvalidStateError(); + throw new InvalidStateError( + `no schema for object store '${this._objectStore._name}'`, + ); } if (!storeSchema.indexes[this._name]) { - throw new InvalidStateError(); + throw new InvalidStateError( + `no schema for index '${this._name}' of object store '${this._objectStore._name}'`, + ); } } get(key: BridgeIDBKeyRange | IDBValidKey) { - this._confirmIndexExists(); - this._confirmActiveTransaction(); if (this._deleted) { throw new InvalidStateError(); } + if (this._objectStore._deleted) { + throw new InvalidStateError(); + } + this._confirmActiveTransaction(); + this._confirmIndexExists(); if (!(key instanceof BridgeIDBKeyRange)) { key = BridgeIDBKeyRange._valueToKeyRange(key); @@ -1595,10 +1602,10 @@ export class BridgeIDBObjectStore implements IDBObjectStore { */ _confirmActiveTransaction(): void { if (!this._transaction._active) { - throw new TransactionInactiveError(); + throw new TransactionInactiveError("transaction is not active"); } if (this._transaction._aborted) { - throw new TransactionInactiveError(); + throw new TransactionInactiveError("transaction has been aborted"); } } -- cgit v1.2.3