Bug 1148217 - catch and log local storage errors in reading-list sync engine. r=adw
authorMark Hammond <mhammond@skippinet.com.au>
Fri, 27 Mar 2015 11:38:07 +1100
changeset 266257 dd53d96466ce63b4b3b480ae48693b5a651a1eac
parent 266256 ed5addaca0c1afc446703f6985ee8ad999f2be02
child 266258 acb7c9364516fcf972c009137167f549938cfd20
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1148217
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1148217 - catch and log local storage errors in reading-list sync engine. r=adw
browser/components/readinglist/Sync.jsm
--- a/browser/components/readinglist/Sync.jsm
+++ b/browser/components/readinglist/Sync.jsm
@@ -399,17 +399,23 @@ SyncImpl.prototype = {
         if (serverRecord.deleted) {
           yield this._deleteItemForGUID(serverRecord.id);
           continue;
         }
         yield this._updateItemWithServerRecord(localItem, serverRecord);
         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});
+      }
     }
   }),
 
   /**
    * Phase 3 (material changes)
    *
    * Uploads not-new items with material changes.
    */
@@ -437,41 +443,56 @@ SyncImpl.prototype = {
    * @param item A local ReadingListItem.
    * @param serverRecord A server record representing the item.
    */
   _updateItemWithServerRecord: Task.async(function* (localItem, serverRecord) {
     if (!localItem) {
       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});
+    }
   }),
 
   /**
    * Truly deletes the local ReadingListItem with the given GUID.
    *
    * @param guid The item's GUID.
    */
   _deleteItemForGUID: Task.async(function* (guid) {
     let item = yield this._itemForGUID(guid);
     if (item) {
       // If item is non-null, then it hasn't been deleted locally.  Therefore
       // it's important to delete it through its list so that the list and its
       // 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
     // been synced and then deleted so that it's marked as being deleted.  In
     // 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});
+    }
   }),
 
   /**
    * Sends a request to the server.
    *
    * @param req The request object: { method, path, body, headers }.
    * @return Promise<response> Resolved with the server's response object:
    *         { status, body, headers }.