Interface FailureWithError

A failure explained by an error: the last attempt ended in an abnormal termination that was not retried.

import assert from "node:assert/strict";
import { LocalExecutor } from "itinera/executor";
import { Step } from "itinera/step";
import { Workflow } from "itinera/workflow";

class Charge extends Step {
override run(): never {
throw new Error("gateway down");
}
}

class Orders extends Workflow {}

export default (async () => {
const orders = Orders.builder()
.name("orders")
.step(Charge.builder("charge"))
.build();
const instance = orders.instance(new Map([["order", "A-1"]]));

const result = await new LocalExecutor().run(instance);

assert.equal(result.journeyId, instance.journeyId);
assert.ok(result.isFailed());
assert.deepEqual(result.status.dataBag.keys(), ["order"]);
assert.equal(result.failure?.cause, "abnormal termination");
assert.equal(result.failure.errorMessage, "gateway down");
assert.equal(result.abort, undefined);
})();
interface FailureWithError {
    cause: "retries exhausted" | "abnormal termination";
    error: unknown;
    errorMessage: string;
    reason?: undefined;
}

Index

cause: "retries exhausted" | "abnormal termination"

Why the journey failed.

error: unknown

What the step threw, as it was thrown.

errorMessage: string

The message of what the step threw: its message for an Error, and its text otherwise.

reason?: undefined

Never present: an error explains this failure, not a reason.