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 parseConfig(err, text) {
function handleConfig(err, config) { function handleConfig(err, config) {
//console.log('CONFIG'); if (err) { throw err; }
//console.log(config);
state.config = config; state.config = config;
var verstrd = [ pkg.name + ' daemon v' + state.config.version ]; var verstrd = [ pkg.name + ' daemon v' + state.config.version ];
if (state.config.version && state.config.version !== pkg.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 = { var parsers = {

View File

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