Why a step failed or was skipped, or why a hook failed the journey: a code, and optionally a message and details, as events and the result carry it.
The details are a value, captured when the reason was given, so changing what was given afterwards changes nothing here.
import assert from "node:assert/strict";import type { Reason } from "itinera/step";function explain(reason: Reason): string { return reason.message === undefined ? reason.code : `${reason.code}: ${reason.message}`;}assert.equal(explain({ code: "declined" }), "declined");assert.equal( explain({ code: "declined", message: "card expired", details: { last4: "4242" }, }), "declined: card expired",); Copy
import assert from "node:assert/strict";import type { Reason } from "itinera/step";function explain(reason: Reason): string { return reason.message === undefined ? reason.code : `${reason.code}: ${reason.message}`;}assert.equal(explain({ code: "declined" }), "declined");assert.equal( explain({ code: "declined", message: "card expired", details: { last4: "4242" }, }), "declined: card expired",);
Readonly
A short code a program can compare, such as "declined".
"declined"
Optional
Anything else the reason says, as a value.
A message for people.
Why a step failed or was skipped, or why a hook failed the journey: a code, and optionally a message and details, as events and the result carry it.
The details are a value, captured when the reason was given, so changing what was given afterwards changes nothing here.