Type Alias ReporterFailure

ReporterFailure:
    | { kind: "first event"; message?: string }
    | { event: EventKind; kind: "on event"; message?: string }
    | { key: string; kind: "on global metadata"; message?: string }

Where a FailingReporter fails: on the first event it receives, on every event of a kind, or on every entry of global metadata under a key, each with the message of the error it throws, or one of its own.

import assert from "node:assert/strict";
import { LocalExecutor } from "itinera/executor";
import { AbortReason } from "itinera/journey";
import { Ending, FailingReporter, stepMock } from "itinera/testing";
import { Workflow } from "itinera/workflow";

class Orders extends Workflow {}

export default (async () => {
const orders = Orders.builder()
.name("orders")
.step(stepMock({ attempts: [Ending.success] }).builder("charge"))
.build();
const reporter = new FailingReporter({
kind: "on event",
event: "step_succeeded",
message: "audit log is full",
});

const result = await new LocalExecutor().run(
orders.instance({}, { reporters: [reporter] }),
);

assert.equal(result.abort?.reason, AbortReason.ReporterFailed);
assert.ok(reporter.failed);
assert.deepEqual(reporter.path, ["charge attempt 1 succeeded"]);
})();

Type Declaration

  • { kind: "first event"; message?: string }
    • Readonlykind: "first event"

      It fails on the first event it receives.

    • Optional Readonlymessage?: string

      The message of the error it throws.

  • { event: EventKind; kind: "on event"; message?: string }
    • Readonlyevent: EventKind

      The kind of event it fails on.

    • Readonlykind: "on event"

      It fails on every event of a kind.

    • Optional Readonlymessage?: string

      The message of the error it throws.

  • { key: string; kind: "on global metadata"; message?: string }
    • Readonlykey: string

      The key of the entries it fails on.

    • Readonlykind: "on global metadata"

      It fails on every entry of global metadata under a key.

    • Optional Readonlymessage?: string

      The message of the error it throws.