Make error message unique
Summary: We're currently getting errors for every duplicate key and can't easily unify them, so we're adding the additional information to a warning instead. Reviewed By: mweststrate Differential Revision: D30337821 fbshipit-source-id: db9dc44d7d3424de169bed9b4447b482e411eb19
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e880059167
commit
797007f367
@@ -12,7 +12,6 @@ import child_process, {ChildProcess} from 'child_process';
|
|||||||
import BaseDevice from '../BaseDevice';
|
import BaseDevice from '../BaseDevice';
|
||||||
import JSONStream from 'JSONStream';
|
import JSONStream from 'JSONStream';
|
||||||
import {Transform} from 'stream';
|
import {Transform} from 'stream';
|
||||||
import {exec} from 'promisify-child-process';
|
|
||||||
import {ERR_PHYSICAL_DEVICE_LOGS_WITHOUT_IDB, IOSBridge} from './IOSBridge';
|
import {ERR_PHYSICAL_DEVICE_LOGS_WITHOUT_IDB, IOSBridge} from './IOSBridge';
|
||||||
import split2 from 'split2';
|
import split2 from 'split2';
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ export function getAllPromisesForQueryingDevices(
|
|||||||
store.getState().settingsState.idbPath,
|
store.getState().settingsState.idbPath,
|
||||||
store.getState().settingsState.enablePhysicalIOS,
|
store.getState().settingsState.enablePhysicalIOS,
|
||||||
).then((devices: IOSDeviceParams[]) => {
|
).then((devices: IOSDeviceParams[]) => {
|
||||||
|
console.log('Active iOS devices:', devices);
|
||||||
processDevices(store, logger, iosBridge, devices, 'physical');
|
processDevices(store, logger, iosBridge, devices, 'physical');
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -212,7 +212,13 @@ export class DataSource<T> {
|
|||||||
if (this.keyAttribute) {
|
if (this.keyAttribute) {
|
||||||
const key = this.getKey(value);
|
const key = this.getKey(value);
|
||||||
if (this._recordsById.has(key)) {
|
if (this._recordsById.has(key)) {
|
||||||
throw new Error(`Duplicate key: '${key}'`);
|
const existingValue = this._recordsById.get(key);
|
||||||
|
console.warn(
|
||||||
|
`Tried to append value with duplicate key: ${key} (key attribute is ${this.keyAttribute}). Old/new values:`,
|
||||||
|
existingValue,
|
||||||
|
value,
|
||||||
|
);
|
||||||
|
throw new Error(`Duplicate key`);
|
||||||
}
|
}
|
||||||
this._recordsById.set(key, value);
|
this._recordsById.set(key, value);
|
||||||
this.storeIndexOfKey(key, this._records.length);
|
this.storeIndexOfKey(key, this._records.length);
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ test('throws on invalid keys', () => {
|
|||||||
}).toThrow(`Invalid key value: ''`);
|
}).toThrow(`Invalid key value: ''`);
|
||||||
expect(() => {
|
expect(() => {
|
||||||
ds.append({id: 'cookie', title: 'test'});
|
ds.append({id: 'cookie', title: 'test'});
|
||||||
}).toThrow(`Duplicate key: 'cookie'`);
|
}).toThrow(`Duplicate key`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws on update causing duplicate key', () => {
|
test('throws on update causing duplicate key', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user