diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-09-03 03:11:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-03 03:11:10 +0000 |
commit | ab6295d0f136b77534e6e290e165b1035c7abdc2 (patch) | |
tree | 5e435a9396979e4307c783f131f251581b955aac /src/background/usecases/SettingUseCase.ts | |
parent | 07bcc15e7b487fb5815b151e8c7e84a31f875dce (diff) | |
parent | f64b7ca320f73dd523113f0eedca35e176843bd6 (diff) |
Merge pull request #638 from ueokande/qa-0.24
QA 0.24
Diffstat (limited to 'src/background/usecases/SettingUseCase.ts')
-rw-r--r-- | src/background/usecases/SettingUseCase.ts | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/background/usecases/SettingUseCase.ts b/src/background/usecases/SettingUseCase.ts index 53c8f1d..d73521f 100644 --- a/src/background/usecases/SettingUseCase.ts +++ b/src/background/usecases/SettingUseCase.ts @@ -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,10 +35,17 @@ export default class SettingUseCase { try { value = data.toSettings(); } catch (e) { - this.notifyPresenter.notifyInvalidSettings(); + 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(); + }); + } } |