Firefox add-on's weird behaviour
I have a preference entry and use below statement to access it's content
var st = easyfa.branch.getComplexValue("mapstr",Components.interfaces.nsIPrefLocalizedString).data;
this throws exception:
*Component returned failure code: 0x804b000a (NS_ERROR_MALFORMED_URI) [nsIPrefBranch.getComplexValue]*
开发者_Go百科
But after setting value of the preference manually (by entering about:config) the error disappears!?
The default value of a localised preference must be a chrome URL to a .properties
file, in which the preference is looked up to locate the resulting string. Assuming the URL points to a locale file, this allows the value to change depending on the installed language.
However you seem to want a simple string preference, which you should retrieve using the nsISupportsString
interface.
Getting the value of a preference that isn't set will always throw. You have to wrap it in a try-catch
block and handle it accordingly.
精彩评论