The thing is the `context` in the summary stage do...
# suitescript
m
The thing is the
context
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 information
r
I used a function I saw in help to logs the errors
Copy code
function 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);
    }
Copy code
function 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") });
        }
    }
m
Thanks