fix: catch write errors for settings
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
3643ecf7d6
commit
64fd1eee68
1 changed files with 5 additions and 1 deletions
|
@ -30,7 +30,11 @@ function createSettingsStore<T extends object = any>(file: string, settings: T)
|
|||
const store = new SettingsStore(settings);
|
||||
store.addGlobalChangeListener(o => {
|
||||
mkdirSync(dirname(file), { recursive: true });
|
||||
writeFileSync(file, JSON.stringify(o, null, 4));
|
||||
try {
|
||||
writeFileSync(file, JSON.stringify(o, null, 4));
|
||||
} catch (err) {
|
||||
console.error(`Failed to save ${file}`, err);
|
||||
}
|
||||
});
|
||||
|
||||
return store;
|
||||
|
|
Reference in a new issue