From 6a10ecf4d59aa6ded36f1a046c955f466e4f9361 Mon Sep 17 00:00:00 2001 From: Lutz Roeder Date: Thu, 27 Jun 2019 18:50:45 -0700 Subject: [PATCH] Handle invalid configuration (#292) --- src/app.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app.js b/src/app.js index ebc287e169..e01b481edd 100644 --- a/src/app.js +++ b/src/app.js @@ -799,21 +799,22 @@ class ViewCollection { class ConfigurationService { load() { + this._data = { 'recents': [] }; var dir = electron.app.getPath('userData'); if (dir && dir.length > 0) { var file = path.join(dir, 'configuration.json'); if (fs.existsSync(file)) { var data = fs.readFileSync(file); if (data) { - this._data = JSON.parse(data); + try { + this._data = JSON.parse(data); + } + catch (error) { + // continue regardless of error + } } } } - if (!this._data) { - this._data = { - 'recents': [] - }; - } } save() {