Display helpful error message if n8n-config file is not valid JSON

This commit is contained in:
Jan Oberhauser 2019-11-10 22:06:11 +01:00
parent 8ffa7a2265
commit 3623828283

View file

@ -159,9 +159,14 @@ export async function getUserSettings(settingsPath?: string, ignoreCache?: boole
}
const settingsFile = await fsReadFile(settingsPath, 'utf8');
settingsCache = JSON.parse(settingsFile);
return JSON.parse(settingsFile) as IUserSettings;
try {
settingsCache = JSON.parse(settingsFile);
} catch (error) {
throw new Error(`Error parsing n8n-config file "${settingsPath}". It does not seem to be valid JSON.`);
}
return settingsCache as IUserSettings;
}