devtools-core icon indicating copy to clipboard operation
devtools-core copied to clipboard

Services.prefs.get*Pref should throw a helpful error message

Open juliandescottes opened this issue 8 years ago • 0 comments

Introducing a new preference and testing it with launchpad can be tricky.

The new preference has to be added in one of the devtools preferences files in order for it to be defined in Firefox. The console & netmonitor also require to set the default value in their respective index.js. (Not sure I remember how the debugger does, cc @jasonLaster ?)

Ideally it would be nice to have a centralized way where all the preferences for devtools are defined, but in the meantime, we should improve the error message thrown when trying to read an undefined preference.

https://github.com/devtools-html/devtools-core/blob/master/packages/devtools-modules/src/Services.js#L324

The message should contain something along the lines of "Unable to find preference {pref}, make sure a default value is defined as expected by the project you are modifying. See [link to documentation]".

I will open a bug on bugzilla to add a documentation page dedicated to that, that will explain how to add a new devtools pref.

juliandescottes avatar Aug 25 '17 13:08 juliandescottes