improve error messages
This commit is contained in:
parent
f797f16e2f
commit
5b43bd857c
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "idb-bridge",
|
"name": "idb-bridge",
|
||||||
"version": "0.0.12",
|
"version": "0.0.13",
|
||||||
"description": "IndexedDB implementation that uses SQLite3 as storage",
|
"description": "IndexedDB implementation that uses SQLite3 as storage",
|
||||||
"main": "./build/index.js",
|
"main": "./build/index.js",
|
||||||
"types": "./build/index.d.ts",
|
"types": "./build/index.d.ts",
|
||||||
|
@ -1329,14 +1329,36 @@ export class MemoryBackend implements Backend {
|
|||||||
key = storeReq.key;
|
key = storeReq.key;
|
||||||
value = storeReq.value;
|
value = storeReq.value;
|
||||||
} else {
|
} else {
|
||||||
const storeKeyResult: StoreKeyResult = makeStoreKeyValue(
|
const keygen =
|
||||||
storeReq.value,
|
|
||||||
storeReq.key,
|
|
||||||
objectStoreMapEntry.store.modifiedKeyGenerator ||
|
objectStoreMapEntry.store.modifiedKeyGenerator ||
|
||||||
objectStoreMapEntry.store.originalKeyGenerator,
|
objectStoreMapEntry.store.originalKeyGenerator;
|
||||||
schema.objectStores[storeReq.objectStoreName].autoIncrement,
|
const autoIncrement =
|
||||||
schema.objectStores[storeReq.objectStoreName].keyPath,
|
schema.objectStores[storeReq.objectStoreName].autoIncrement;
|
||||||
);
|
const keyPath = schema.objectStores[storeReq.objectStoreName].keyPath;
|
||||||
|
let storeKeyResult: StoreKeyResult;
|
||||||
|
try {
|
||||||
|
storeKeyResult = makeStoreKeyValue(
|
||||||
|
storeReq.value,
|
||||||
|
storeReq.key,
|
||||||
|
keygen,
|
||||||
|
autoIncrement,
|
||||||
|
keyPath,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof DataError) {
|
||||||
|
const kp = JSON.stringify(keyPath);
|
||||||
|
const n = storeReq.objectStoreName;
|
||||||
|
const m = `Could not extract key from value, objectStore=${n}, keyPath=${kp}`;
|
||||||
|
if (this.enableTracing) {
|
||||||
|
console.error(e);
|
||||||
|
console.error("value was:", storeReq.value);
|
||||||
|
console.error("key was:", storeReq.key);
|
||||||
|
}
|
||||||
|
throw new DataError(m);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
key = storeKeyResult.key;
|
key = storeKeyResult.key;
|
||||||
value = storeKeyResult.value;
|
value = storeKeyResult.value;
|
||||||
objectStoreMapEntry.store.modifiedKeyGenerator =
|
objectStoreMapEntry.store.modifiedKeyGenerator =
|
||||||
|
Loading…
Reference in New Issue
Block a user