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
--- 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) {