In case there is an error parsing one of the messages in a file, catch rather than blowing up
This commit is contained in:
@@ -257,11 +257,15 @@ 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);
|
||||||
|
} catch (e) {
|
||||||
|
errorState = true;
|
||||||
|
return void cb(err);
|
||||||
|
}
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
errorState = true;
|
errorState = true;
|
||||||
@@ -270,11 +274,6 @@ var getMessages = function (env, chanName, handler, cb) {
|
|||||||
chan.atime = +new Date();
|
chan.atime = +new Date();
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
} catch (err2) {
|
|
||||||
console.error(err2);
|
|
||||||
cb(err2);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user