From f4afe9847d8f7e1487d99b127ac56be5541dd243 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Mon, 2 Jul 2018 19:32:27 -0600 Subject: [PATCH] Handle bad config.hjson at startup/re-cache: output to stderr --- core/bbs.js | 22 ++++++++++++---------- core/config.js | 2 ++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/core/bbs.js b/core/bbs.js index 86134c38..4436eb02 100644 --- a/core/bbs.js +++ b/core/bbs.js @@ -75,10 +75,10 @@ function main() { configPathSupplied = null; // make non-fatal; we'll go with defaults } } else { - console.error(err.toString()); + console.error(err.message); } } - callback(err); + return callback(err); }); }, function initSystem(callback) { @@ -91,14 +91,16 @@ function main() { } ], function complete(err) { - // note this is escaped: - fs.readFile(paths.join(__dirname, '../misc/startup_banner.asc'), 'utf8', (err, banner) => { - console.info(FULL_COPYRIGHT); - if(!err) { - console.info(banner); - } - console.info('System started!'); - }); + if(!err) { + // note this is escaped: + fs.readFile(paths.join(__dirname, '../misc/startup_banner.asc'), 'utf8', (err, banner) => { + console.info(FULL_COPYRIGHT); + if(!err) { + console.info(banner); + } + console.info('System started!'); + }); + } if(err) { console.error('Error initializing: ' + util.inspect(err)); diff --git a/core/config.js b/core/config.js index 92016731..6d5251a3 100644 --- a/core/config.js +++ b/core/config.js @@ -100,6 +100,8 @@ function init(configPath, options, cb) { Events.emit(Events.getSystemEvents().ConfigChanged); } }); + } else { + console.stdout(`Configuration ${reCachedPath} is invalid: ${err.message}`); // eslint-disable-line no-console } }); };