Fix undefined checking on operation parameter
This commit is contained in:
parent
52e7a3aa11
commit
04c077d614
2 changed files with 29 additions and 15 deletions
|
@ -21,7 +21,12 @@ export default class SettingUseCase {
|
|||
}
|
||||
|
||||
async reload(): Promise<Settings> {
|
||||
let data = await this.persistentSettingRepository.load();
|
||||
let data;
|
||||
try {
|
||||
data = await this.persistentSettingRepository.load();
|
||||
} catch (e) {
|
||||
this.showUnableToLoad(e);
|
||||
}
|
||||
if (!data) {
|
||||
data = DefaultSettingData;
|
||||
}
|
||||
|
@ -30,12 +35,17 @@ export default class SettingUseCase {
|
|||
try {
|
||||
value = data.toSettings();
|
||||
} catch (e) {
|
||||
this.notifyPresenter.notifyInvalidSettings(() => {
|
||||
browser.runtime.openOptionsPage();
|
||||
});
|
||||
this.showUnableToLoad(e);
|
||||
value = DefaultSettingData.toSettings();
|
||||
}
|
||||
this.settingRepository.update(value!!);
|
||||
return value;
|
||||
}
|
||||
|
||||
private showUnableToLoad(e: Error) {
|
||||
console.error('unable to load settings', e);
|
||||
this.notifyPresenter.notifyInvalidSettings(() => {
|
||||
browser.runtime.openOptionsPage();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue