Bug 1251916 - Use standard JavaScript features in toolkit/components/passwordmgr to pass eslint checks: replace conditional catch statements. r=MattN
authorSebastian Hengst <archaeopteryx@coole-files.de>
Sun, 28 Feb 2016 14:11:30 -0800
changeset 322127 c9d21264b345528d66b677427c578bb19759b418
parent 322126 eca3aa5d534c693e362d6d5f8940f2b8030ca620
child 322128 2b65183b927679673b4ce57a84da407f558160a0
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1251916
milestone47.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 1251916 - Use standard JavaScript features in toolkit/components/passwordmgr to pass eslint checks: replace conditional catch statements. r=MattN While it doesn't seem like this SpiderMonkey feature will go away soon, replacing it makes tooling easier and is suitable here because the unconditional catch js already used. MozReview-Commit-ID: 3G3LxrW24HF
toolkit/components/passwordmgr/nsLoginManagerPrompter.js
toolkit/components/passwordmgr/storage-mozStorage.js
--- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
@@ -103,22 +103,24 @@ LoginManagerPromptFactory.prototype = {
     var runnable = {
       run : function() {
         var ok = false;
         try {
           self.log("_doAsyncPrompt:run - performing the prompt for '" + hashKey + "'");
           ok = prompter.promptAuth(prompt.channel,
                                    prompt.level,
                                    prompt.authInfo);
-        } catch (e if (e instanceof Components.Exception) &&
-                       e.result == Cr.NS_ERROR_NOT_AVAILABLE) {
-          self.log("_doAsyncPrompt:run bypassed, UI is not available in this context");
         } catch (e) {
-          Components.utils.reportError("LoginManagerPrompter: " +
-              "_doAsyncPrompt:run: " + e + "\n");
+          if (e instanceof Components.Exception &&
+              e.result == Cr.NS_ERROR_NOT_AVAILABLE) {
+            self.log("_doAsyncPrompt:run bypassed, UI is not available in this context");
+          } else {
+            Components.utils.reportError("LoginManagerPrompter: " +
+                                         "_doAsyncPrompt:run: " + e + "\n");
+          }
         }
 
         delete self._asyncPrompts[hashKey];
         prompt.inProgress = false;
         self._asyncPromptInProgress = false;
 
         for (var consumer of prompt.consumers) {
           if (!consumer.callback)
--- a/toolkit/components/passwordmgr/storage-mozStorage.js
+++ b/toolkit/components/passwordmgr/storage-mozStorage.js
@@ -1012,20 +1012,22 @@ LoginManagerStorage_mozStorage.prototype
       // database has not been created yet.
       let version = this._dbConnection.schemaVersion;
       if (version == 0) {
         this._dbCreate();
         isFirstRun = true;
       } else if (version != DB_VERSION) {
         this._dbMigrate(version);
       }
-    } catch (e if e.result == Cr.NS_ERROR_FILE_CORRUPTED) {
-      // Database is corrupted, so we backup the database, then throw
-      // causing initialization to fail and a new db to be created next use
-      this._dbCleanup(true);
+    } catch (e) {
+      if (e.result == Cr.NS_ERROR_FILE_CORRUPTED) {
+        // Database is corrupted, so we backup the database, then throw
+        // causing initialization to fail and a new db to be created next use
+        this._dbCleanup(true);
+      }
       throw e;
     }
 
     Services.obs.addObserver(this, "profile-before-change", false);
     return isFirstRun;
   },
 
   observe: function (subject, topic, data) {