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:
@@ -101,7 +101,9 @@
|
|||||||
this.preferences = preferenceStore().get( this.preferenceName );
|
this.preferences = preferenceStore().get( this.preferenceName );
|
||||||
} else {
|
} else {
|
||||||
var options = mw.user.options.get( this.preferenceName );
|
var options = mw.user.options.get( this.preferenceName );
|
||||||
|
if ( !options ) {
|
||||||
|
options = '{}';
|
||||||
|
}
|
||||||
// Try to parse JSON
|
// Try to parse JSON
|
||||||
try {
|
try {
|
||||||
this.preferences = JSON.parse( options );
|
this.preferences = JSON.parse( options );
|
||||||
|
|||||||
Reference in New Issue
Block a user