aboutsummaryrefslogtreecommitdiff
path: root/src/background
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-08-27 22:33:33 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-08-28 22:18:23 +0900
commit04c077d614b3eae95da1e9b506171a87948a4179 (patch)
tree3eeccebf6389e53bcb85e6aeacc7a8ccc83d9c6c /src/background
parent52e7a3aa11ffd3d90e4ecde886ac93bbf2579f73 (diff)
Fix undefined checking on operation parameter
Diffstat (limited to 'src/background')
-rw-r--r--src/background/usecases/SettingUseCase.ts18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/background/usecases/SettingUseCase.ts b/src/background/usecases/SettingUseCase.ts
index ee131c7..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,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();
+ });
+ }
}