In case there is an error parsing one of the messages in a file, catch rather than blowing up

This commit is contained in:
Caleb James DeLisle
2018-01-16 11:51:09 +01:00
parent ee605183e5
commit f3167964f4

View File

@@ -257,24 +257,23 @@ var getMessages = function (env, chanName, handler, cb) {
return;
}
var errorState = false;
try {
readMessages(chan.path, function (msg) {
if (!msg || errorState) { return; }
//console.log(msg);
readMessages(chan.path, function (msg) {
if (!msg || errorState) { return; }
//console.log(msg);
try {
handler(msg);
}, function (err) {
if (err) {
errorState = true;
return void cb(err);
}
chan.atime = +new Date();
cb();
});
} catch (err2) {
console.error(err2);
cb(err2);
return;
}
} catch (e) {
errorState = true;
return void cb(err);
}
}, function (err) {
if (err) {
errorState = true;
return void cb(err);
}
chan.atime = +new Date();
cb();
});
});
};