Skip to content

Commit

Permalink
Improve error message when user forgot to call Store.initRenderer() (
Browse files Browse the repository at this point in the history
  • Loading branch information
MehediH committed Feb 11, 2021
1 parent 7e6fa09 commit a61f9ea
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ class ElectronStore extends Conf {
// If we are in the renderer process, we communicate with the main process
// to get the required data for the module otherwise, we pull from the main process.
if (ipcRenderer) {
({defaultCwd, appVersion} = ipcRenderer.sendSync('electron-store-get-data'));
const appData = ipcRenderer.sendSync('electron-store-get-data');

if (!appData) {
throw new Error('Electron Store: You need to call `.initRenderer()` from the main process.');
}

({defaultCwd, appVersion} = appData);
} else if (ipcMain && app) {
({defaultCwd, appVersion} = initDataListener());
}
Expand Down

0 comments on commit a61f9ea

Please sign in to comment.