aboutsummaryrefslogtreecommitdiff
path: root/src/background/usecases/SettingUseCase.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/usecases/SettingUseCase.ts')
-rw-r--r--src/background/usecases/SettingUseCase.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/background/usecases/SettingUseCase.ts b/src/background/usecases/SettingUseCase.ts
index fd00f80..53c8f1d 100644
--- a/src/background/usecases/SettingUseCase.ts
+++ b/src/background/usecases/SettingUseCase.ts
@@ -4,6 +4,7 @@ import PersistentSettingRepository
import SettingRepository from '../repositories/SettingRepository';
import { DefaultSettingData } from '../../shared/SettingData';
import Settings from '../../shared/Settings';
+import NotifyPresenter from '../presenters/NotifyPresenter';
@injectable()
export default class SettingUseCase {
@@ -11,6 +12,7 @@ export default class SettingUseCase {
constructor(
private persistentSettingRepository: PersistentSettingRepository,
private settingRepository: SettingRepository,
+ private notifyPresenter: NotifyPresenter,
) {
}
@@ -24,8 +26,14 @@ export default class SettingUseCase {
data = DefaultSettingData;
}
- let value = data.toSettings();
- this.settingRepository.update(value);
+ let value: Settings;
+ try {
+ value = data.toSettings();
+ } catch (e) {
+ this.notifyPresenter.notifyInvalidSettings();
+ value = DefaultSettingData.toSettings();
+ }
+ this.settingRepository.update(value!!);
return value;
}
}