minor cleanup, throw on previously unchecked error

Этот коммит содержится в:
AJ ONeal 2018-11-04 14:28:07 -07:00
родитель d5a622444e
Коммит 75f538fa16
2 изменённых файлов: 11 добавлений и 8 удалений

Просмотреть файл

@ -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 = {

Просмотреть файл

@ -39,15 +39,18 @@ 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";
}
try {
body = JSON.parse(body);
} catch(e) {
// ignore
if (body) {
try {
body = JSON.parse(body);
} catch(e) {
console.error('Error:', err);
// ignore
}
}
fn(err, body);