Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug 720641 (gtgcli): Fix Firefox Settings implementation

- the try/catch block is redundant, and hides errors
- calling .toString() on BOOL/INT is a new level of stupid
  • Loading branch information...
commit a91929bac3dbd0f14561f0cc2b0cfe1c85622bb6 1 parent a0b092b
@joewalker authored
Showing with 20 additions and 25 deletions.
  1. +20 −25 mozilla/gcli/settings.js
View
45 mozilla/gcli/settings.js
@@ -98,31 +98,26 @@ Object.defineProperty(Setting.prototype, 'type', {
*/
Object.defineProperty(Setting.prototype, 'value', {
get: function() {
- try {
- switch (imports.prefBranch.getPrefType(this.name)) {
- case imports.prefBranch.PREF_BOOL:
- return imports.prefBranch.getBoolPref(this.name).toString();
-
- case imports.prefBranch.PREF_INT:
- return imports.prefBranch.getIntPref(this.name).toString();
-
- case imports.prefBranch.PREF_STRING:
- var value = imports.prefBranch.getComplexValue(this.name,
- Components.interfaces.nsISupportsString).data;
- // Try in case it's a localized string (will throw an exception if not)
- var isL10n = /^chrome:\/\/.+\/locale\/.+\.properties/.test(value);
- if (!this.changed && isL10n) {
- value = imports.prefBranch.getComplexValue(this.name,
- Components.interfaces.nsIPrefLocalizedString).data;
- }
- return value;
-
- default:
- throw new Error('Invalid value for ' + this.name);
- }
- } catch (ex) {
- // Also catch obscure cases in which you can't tell in advance
- // that the pref exists but has no user or default value...
+ switch (imports.prefBranch.getPrefType(this.name)) {
+ case imports.prefBranch.PREF_BOOL:
+ return imports.prefBranch.getBoolPref(this.name);
+
+ case imports.prefBranch.PREF_INT:
+ return imports.prefBranch.getIntPref(this.name);
+
+ case imports.prefBranch.PREF_STRING:
+ var value = imports.prefBranch.getComplexValue(this.name,
+ Components.interfaces.nsISupportsString).data;
+ // Try in case it's a localized string (will throw an exception if not)
+ var isL10n = /^chrome:\/\/.+\/locale\/.+\.properties/.test(value);
+ if (!this.changed && isL10n) {
+ value = imports.prefBranch.getComplexValue(this.name,
+ Components.interfaces.nsIPrefLocalizedString).data;
+ }
+ return value;
+
+ default:
+ throw new Error('Invalid value for ' + this.name);
}
},
enumerable: true
Please sign in to comment.
Something went wrong with that request. Please try again.