Bug 707329 - Folder panel has no content. JSON.parse: unexpected end of data Source File: chrome://messenger/content/folderPane.js. Correctly handle a corrupted file. r=bienvenu,ui-review=bwinton,a=Standard8
authorMark Banner <bugzilla@standard8.plus.com>
Wed, 11 Jan 2012 13:58:55 +0000
changeset 11264 381fce93589937ec32ef1ab3e530691e8e1cd8df
parent 11263 076bf34c86a0e6cad62da828c378a7a544a48fb4
child 11265 d42be64ed94ca07f0d27f151eca159ec565317d8
push id6
push userbienvenu@nventure.com
push dateWed, 16 May 2012 22:24:51 +0000
treeherdertry-comm-central@ac395aea3008 [default view] [failures only]
reviewersbienvenu, Standard8
bugs707329
Bug 707329 - Folder panel has no content. JSON.parse: unexpected end of data Source File: chrome://messenger/content/folderPane.js. Correctly handle a corrupted file. r=bienvenu,ui-review=bwinton,a=Standard8
mail/base/content/folderPane.js
--- a/mail/base/content/folderPane.js
+++ b/mail/base/content/folderPane.js
@@ -1,9 +1,8 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
@@ -188,17 +187,22 @@ let gFolderTreeView = {
         fstream.init(file, -1, 0, 0);
         sstream.init(fstream);
 
         while (sstream.available())
           data += sstream.read(4096);
 
         sstream.close();
         fstream.close();
-        this._persistOpenMap = JSON.parse(data);
+        try {
+          this._persistOpenMap = JSON.parse(data);
+        } catch (x) {
+          Components.utils.reportError(
+            "Failed to read file: " + aJSONFile + " reason: " + x);
+        }
       }
     }
 
     // Load our data
     this._rebuild();
     // And actually draw the tree
     aTree.view = this;