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; return;
} }
var errorState = false; var errorState = false;
try { readMessages(chan.path, function (msg) {
readMessages(chan.path, function (msg) { if (!msg || errorState) { return; }
if (!msg || errorState) { return; } //console.log(msg);
//console.log(msg); try {
handler(msg); handler(msg);
}, function (err) { } catch (e) {
if (err) { errorState = true;
errorState = true; return void cb(err);
return void cb(err); }
} }, function (err) {
chan.atime = +new Date(); if (err) {
cb(); errorState = true;
}); return void cb(err);
} catch (err2) { }
console.error(err2); chan.atime = +new Date();
cb(err2); cb();
return; });
}
}); });
}; };