Skip to content

Commit a61f9ea

Browse files
authored
Improve error message when user forgot to call Store.initRenderer() (#166)
1 parent 7e6fa09 commit a61f9ea

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ class ElectronStore extends Conf {
2929
// If we are in the renderer process, we communicate with the main process
3030
// to get the required data for the module otherwise, we pull from the main process.
3131
if (ipcRenderer) {
32-
({defaultCwd, appVersion} = ipcRenderer.sendSync('electron-store-get-data'));
32+
const appData = ipcRenderer.sendSync('electron-store-get-data');
33+
34+
if (!appData) {
35+
throw new Error('Electron Store: You need to call `.initRenderer()` from the main process.');
36+
}
37+
38+
({defaultCwd, appVersion} = appData);
3339
} else if (ipcMain && app) {
3440
({defaultCwd, appVersion} = initDataListener());
3541
}

0 commit comments

Comments
 (0)