From 3623828283b2bcd81d23347ed04f55005ee7a060 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Sun, 10 Nov 2019 22:06:11 +0100 Subject: [PATCH] :zap: Display helpful error message if n8n-config file is not valid JSON --- packages/core/src/UserSettings.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/core/src/UserSettings.ts b/packages/core/src/UserSettings.ts index dd97b9f406..af32d5e36c 100644 --- a/packages/core/src/UserSettings.ts +++ b/packages/core/src/UserSettings.ts @@ -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; }