Interface UnexpectedResultReturned

The dispatcher factory, or the constructor of one of the workflow's policies, returned something its call cannot return, such as undefined, which only a cast or any lets through. It is not a failure of that code, so the refusal carries no error.

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

class Ship extends Step {
override run(): Outcome {
return this.succeed();
}
}

class Orders extends Workflow {}

export default (async () => {
const orders = Orders.builder()
.name("orders")
.step(Ship.builder("ship"))
.build();
const executor = new LocalExecutor();
const instance = orders.instance();

const running = executor.run(instance);
await assert.rejects(executor.run(orders.instance()), {
name: "Refusal",
refused: { kind: "journey running" },
});
assert.ok((await running).isSucceeded());

await assert.rejects(executor.run(instance), Refusal);
await assert.rejects(executor.run(instance), {
refused: { kind: "instance ran" },
message:
"run refused an instance that already ran: make an instance for each journey",
});
})();
interface UnexpectedResultReturned {
    kind: "unexpected result";
    message: string;
    source:
        | { kind: "dispatcher factory" }
        | { kind: "workflow policy"; policy: PolicyName };
}

Index

kind: "unexpected result"

Tells this refusal from the others.

message: string

What was returned, and by whom, for the people reading it.

source:
    | { kind: "dispatcher factory" }
    | { kind: "workflow policy"; policy: PolicyName }

What returned it.

Type Declaration

  • { kind: "dispatcher factory" }
    • Readonlykind: "dispatcher factory"

      The executor's dispatcher factory returned it.

  • { kind: "workflow policy"; policy: PolicyName }
    • Readonlykind: "workflow policy"

      The constructor of a workflow policy returned it.

    • Readonlypolicy: PolicyName

      The name of that policy.