RE: Log Errors in Summarize Phase of Map/Reduce
I’m having trouble logging errors during the summarize phase of a map/reduce script.
My understanding is that each phase essentially has a built-in try/catch and any errors thrown automatically get written to the summarize context, which you can then iterate through and log during the summarize phase. However, when I log the summarize context object just to see it, there are never any errors to iterate through, even when I know I’ve triggered one.
Ultimately, I’m trying to create a task to execute a different script during the summarize phase only if there are no errors during the first script execution. But I need to find the errors array in the context object to do that.
Anyone know what I’m missing?
function summarize(context) {
if (context.inputSummary.error) {
log.error('Input Error', context.inputSummary.error);
}
context.mapSummary.errors.iterator().each(function (key, error) {
log.error('Map Error for key: ' + key, error);
return true;
});
context.reduceSummary.errors.iterator().each(function (key, error) {
log.error('Reduce Error for key: ' + key, error);
return true;
});
}
Don’t know if this would be of help, this is how we track logs in the summarize phase.
Thank you!