Handle bad config.hjson at startup/re-cache: output to stderr

This commit is contained in:
Bryan Ashby 2018-07-02 19:32:27 -06:00
parent a9e2551ae5
commit f4afe9847d
2 changed files with 14 additions and 10 deletions

View File

@ -75,10 +75,10 @@ function main() {
configPathSupplied = null; // make non-fatal; we'll go with defaults configPathSupplied = null; // make non-fatal; we'll go with defaults
} }
} else { } else {
console.error(err.toString()); console.error(err.message);
} }
} }
callback(err); return callback(err);
}); });
}, },
function initSystem(callback) { function initSystem(callback) {
@ -91,6 +91,7 @@ function main() {
} }
], ],
function complete(err) { function complete(err) {
if(!err) {
// note this is escaped: // note this is escaped:
fs.readFile(paths.join(__dirname, '../misc/startup_banner.asc'), 'utf8', (err, banner) => { fs.readFile(paths.join(__dirname, '../misc/startup_banner.asc'), 'utf8', (err, banner) => {
console.info(FULL_COPYRIGHT); console.info(FULL_COPYRIGHT);
@ -99,6 +100,7 @@ function main() {
} }
console.info('System started!'); console.info('System started!');
}); });
}
if(err) { if(err) {
console.error('Error initializing: ' + util.inspect(err)); console.error('Error initializing: ' + util.inspect(err));

View File

@ -100,6 +100,8 @@ function init(configPath, options, cb) {
Events.emit(Events.getSystemEvents().ConfigChanged); Events.emit(Events.getSystemEvents().ConfigChanged);
} }
}); });
} else {
console.stdout(`Configuration ${reCachedPath} is invalid: ${err.message}`); // eslint-disable-line no-console
} }
}); });
}; };