flecs icon indicating copy to clipboard operation
flecs copied to clipboard

Validate config.json on launch

Open Araxeus opened this issue 2 years ago • 0 comments

Currently, if config.json is corrupted somehow, the app just won't launch / shows a white window / error, which makes it very hard for users to fix

image

error thrown from https://github.com/th-ch/youtube-music/blob/23058729f3965deb0bff9b638feb5d419da6e913/config/store.js#L79-L83

To fix this I propose either:

  1. - clearInvalidConfig: false,
    + clearInvalidConfig: true,
    
  2. wrap the Store constructor inside a try...catch, on catch prompt the user:
    Error in config.json 
    "SyntaxError: Unexpected string in JSON at position 2950"
    reset the config to its default options?
    
    then reset if yes / quit if no

bonus: validate schema when changing values https://github.com/sindresorhus/electron-store#schema even more bonus: validate schema on launch

Araxeus avatar Apr 20 '22 12:04 Araxeus