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,14 +91,16 @@ function main() {
} }
], ],
function complete(err) { function complete(err) {
// note this is escaped: if(!err) {
fs.readFile(paths.join(__dirname, '../misc/startup_banner.asc'), 'utf8', (err, banner) => { // note this is escaped:
console.info(FULL_COPYRIGHT); fs.readFile(paths.join(__dirname, '../misc/startup_banner.asc'), 'utf8', (err, banner) => {
if(!err) { console.info(FULL_COPYRIGHT);
console.info(banner); if(!err) {
} console.info(banner);
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
} }
}); });
}; };