michoel
03/27/2019, 12:42 AMcontext
in the summary stage doesn't serialize nicely, I was just doing log.debug({ title: 'summarize', details: context });
and it didn't include any of the error informationrustyshackles
03/27/2019, 12:47 AMrustyshackles
03/27/2019, 12:48 AMfunction handleErrorIfAny (summary) {
log.audit({ title: "handleErrorIfAny", details: "summary: " + JSON.stringify(summary) });
var inputSummary = summary.inputSummary;
var mapSummary = summary.mapSummary;
var reduceSummary = summary.reduceSummary;
if (inputSummary.error) {
var e;
require(["N/error"], function (error) {
e = error.create({
name: "INPUT_STAGE_FAILED",
message: inputSummary.error
});
});
handleErrorAndSendNotification(e, "getInputData");
}
handleErrorInStage("map", mapSummary);
handleErrorInStage("reduce", reduceSummary);
}
rustyshackles
03/27/2019, 12:48 AMfunction handleErrorInStage (stage, summary) {
log.audit({
title: "handleErrorInStage",
details: "Stage: " + stage + " | summary: " + JSON.stringify(summary)
});
var errorMsg = [];
summary.errors.iterator().each(function (key, value) {
var msg = "Failure to create custom record. Internal Id: " + key + ". Error was: " + JSON.parse(value).message + "\n";
errorMsg.push(msg);
return true;
});
if (errorMsg.length > 0) {
log.audit({ title: "handleErrorInStage", details: errorMsg.join("\n") });
}
}
michoel
03/27/2019, 12:52 AM