Avoid (safe) exception by using empty options

Using try-catch block to handle common case of empty options isn't nice.
Avoid it be replacing options to valid JSON

Change-Id: I5b64f7f9a76a94d9c07face8059beab59d4aef93
This commit is contained in:
eranroz
2015-07-16 13:13:57 +03:00
parent 71e8c91d3e
commit 301520f3fd

View File

@@ -101,7 +101,9 @@
this.preferences = preferenceStore().get( this.preferenceName );
} else {
var options = mw.user.options.get( this.preferenceName );
if ( !options ) {
options = '{}';
}
// Try to parse JSON
try {
this.preferences = JSON.parse( options );