Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show error message if configuration is invalid #1224

Merged
18 changes: 12 additions & 6 deletions app/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ const { LucidLog } = require('lucid-log');
let logger;

function getConfigFile(configPath) {
try {
return require(path.join(configPath, 'config.json'));
} catch (e) {
return null;
}
return require(path.join(configPath, 'config.json'));
}

function argv(configPath, appVersion) {
let configFile = getConfigFile(configPath);
configPath = "/home/kwe/dev_private/teams-for-linux/"
woernsn marked this conversation as resolved.
Show resolved Hide resolved
let configFile = null;
let configError = null;
try {
configFile = getConfigFile(configPath);
} catch (e) {
configError = e.message;
}
const missingConfig = configFile == null;
configFile = configFile || {};
let config = yargs
Expand Down Expand Up @@ -268,6 +271,9 @@ function argv(configPath, appVersion) {
})
.parse(process.argv.slice(1));

if (configError) {
config['error'] = configError
}
logger = new LucidLog({
levels: config.appLogLevels.split(',')
});
Expand Down
7 changes: 6 additions & 1 deletion app/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app, ipcMain, desktopCapturer, systemPreferences, powerMonitor, Notification, nativeImage } = require('electron');
const { app, dialog, ipcMain, desktopCapturer, systemPreferences, powerMonitor, Notification, nativeImage } = require('electron');
const path = require('path');
const fs = require('fs');
const { LucidLog } = require('lucid-log');
Expand Down Expand Up @@ -217,6 +217,11 @@ function onAppTerminated(signal) {
}

function handleAppReady() {
// check for configuration errors
if (config.error) {
dialog.showErrorBox('Configuration error', config.error)
}

if (config.isCustomBackgroundEnabled) {
downloadCustomBGServiceRemoteConfig();
}
Expand Down