reduceSummary.errors
Property Description |
Holds all serialized errors thrown from the reduce(reduceContext) function. May also hold the |
Type |
iterator |
Since |
2015.2 |
Members
Member |
Type |
Required/Optional |
Description |
---|---|---|---|
iterator().each(parameters) |
function |
required |
Executes one time for each error. |
parameters
Member |
Type |
Required/Optional |
Description |
---|---|---|---|
iteratorFunction(key, error, executionNo) See also functionParameters. |
function |
required |
Provides logic to be executed during each iteration. |
functionParameters
Parameter |
Type |
Required/Optional |
Description |
---|---|---|---|
key |
string |
optional |
Represents a key that was passed to the reduce stage for processing. |
error |
string |
optional |
A serialization of the error thrown. |
executionNo |
number |
optional |
Indicates whether the error occurred during the first, second, third, or fourth attempt to process the key. |
Syntax
The following snippets shows three ways you could use this iterator.
This code is not a functional example. For a complete script sample, see Map/Reduce Script Samples.
//Add additional code
...
// Create a log entry showing each full serialized error.
summary.reduceSummary.errors.iterator().each(function (key, error, executionNo){
log.error({
title: 'Reduce error for key: ' + key + ', execution no. ' + executionNo,
details: error
});
return true;
});
// Log only the name and description of each error thrown.
summary.reduceSummary.errors.iterator().each(function (key, error){
var errorObject = JSON.parse(error);
log.error({
title: 'Reduce error for key: ' + key + ', execution no. ' + executionNo,
details: errorObject.name + ': ' + errorObject.message
});
return true;
});
// Calculate and log the total number of errors encountered during the reduce stage.
var errorCount = 0;
summary.reduceSummary.errors.iterator().each(function() {
errorCount ++;
return true;
});
log.audit ({
title: 'Reduce stage errors',
details: 'Total number of errors: ' + errorCount
});