aboutsummaryrefslogtreecommitdiff
path: root/src/background
diff options
context:
space:
mode:
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();
+ });
+ }
}