Bug 1148217 - catch and log local storage errors in reading-list sync engine. r=adw

--HG--
extra : rebase_source : d453f866d36cdfb5733041c9019b2fc9fa3fd122
This commit is contained in:
Mark Hammond 2015-03-27 11:38:07 +11:00
Родитель 250b0980be
Коммит ad9785e5d1
1 изменённых файлов: 25 добавлений и 4 удалений

Просмотреть файл

@ -404,7 +404,13 @@ SyncImpl.prototype = {
continue;
}
// new item
yield this.list.addItem(localRecordFromServerRecord(serverRecord));
let localRecord = localRecordFromServerRecord(serverRecord);
try {
yield this.list.addItem(localRecord);
} catch (ex) {
log.warn("Failed to add a new item from server record ${serverRecord}: ${ex}",
{serverRecord, ex});
}
}
}),
@ -442,7 +448,12 @@ SyncImpl.prototype = {
throw new Error("Item should exist");
}
localItem._record = localRecordFromServerRecord(serverRecord);
yield this.list.updateItem(localItem);
try {
yield this.list.updateItem(localItem);
} catch (ex) {
log.warn("Failed to update an item from server record ${serverRecord}: ${ex}",
{serverRecord, ex});
}
}),
/**
@ -458,7 +469,12 @@ SyncImpl.prototype = {
// consumers are notified properly. Set the syncStatus to NEW so that the
// list truly deletes the item.
item._record.syncStatus = ReadingList.SyncStatus.NEW;
yield this.list.deleteItem(item);
try {
yield this.list.deleteItem(item);
} catch (ex) {
log.warn("Failed delete local item with id ${guid}: ${ex}",
{guid, ex});
}
return;
}
// If item is null, then it may not actually exist locally, or it may have
@ -466,7 +482,12 @@ SyncImpl.prototype = {
// that case, try to delete it directly from the store. As far as the list
// is concerned, the item has already been deleted.
log.debug("Item not present in list, deleting it by GUID instead");
this.list._store.deleteItemByGUID(guid);
try {
this.list._store.deleteItemByGUID(guid);
} catch (ex) {
log.warn("Failed to delete local item with id ${guid}: ${ex}",
{guid, ex});
}
}),
/**