Skip to main content
Version: LOC v0.10 (legacy)

Result Aggregator

Parse trigger payload to JSON and write to the session storage.

Logic typeInputOutput
AggregatorSession variable result (type: any, optional)None
note

The logic will finalise and return the error if any occurred in the task, but it would not be able to indicate where it had occurred. You can pass additional session data in other logic to include the context metadata.

result-aggregator.js
import {
ResultAgent,
LoggingAgent,
SessionStorageAgent,
} from "@fstnetwork/loc-logic-sdk";

export async function run(ctx) {
// read result from session
const result = await SessionStorageAgent.get("result");

// logging
LoggingAgent.info({ result: result });

// finalise result
ResultAgent.finalize({
status: "ok",
taskKey: ctx.task.taskKey,
data: result,
});
}

export async function handleError(ctx, error) {
const err = {
error: true,
errorMessage: error.message,
stack: error.stack,
taskKey: ctx.task.taskKey,
};

// error logging
LoggingAgent.error(err);

// finalise result
ResultAgent.finalize(err).httpStatusCode(500);
}