minor cleanup, throw on previously unchecked error

This commit is contained in:
AJ ONeal 2018-11-04 14:28:07 -07:00
parent d5a622444e
commit 75f538fa16
2 changed files with 11 additions and 8 deletions

View File

@ -306,8 +306,8 @@ var RC;
function parseConfig(err, text) {
function handleConfig(err, config) {
//console.log('CONFIG');
//console.log(config);
if (err) { throw err; }
state.config = config;
var verstrd = [ pkg.name + ' daemon v' + state.config.version ];
if (state.config.version && state.config.version !== pkg.version) {
@ -652,7 +652,7 @@ function parseConfig(err, text) {
});
}
RC.request({ service: 'config', method: 'GET' }, handleRemoteRequest('config', handleConfig));
RC.request({ service: 'config', method: 'GET' }, handleConfig);
}
var parsers = {

View File

@ -39,16 +39,19 @@ module.exports.create = function (state) {
var err;
if (200 !== resp.statusCode) {
err = new Error(body || ('get' + service + ' failed'));
err = new Error(body || ('get ' + service + ' failed'));
err.statusCode = resp.statusCode;
err.code = "E_REQUEST";
}
if (body) {
try {
body = JSON.parse(body);
} catch(e) {
console.error('Error:', err);
// ignore
}
}
fn(err, body);
}