Skip to content

Glossary ​

The terms of @sekhmet/issue's ubiquitous language, each named the way the code names it. Terms Sekhmet's packages share live in the root glossary; this page links there instead of redefining them. The concepts explain why each term behaves as it does.

Issues ​

  • Issue (Issue<T, R>): one occurrence of something going wrong. It has a permanent code, a message, an optional hint and docs link, and an issue state that switches in place, once. It is invariant in both T and R, since it changes in place.
  • Code (code): the permanent, machine-readable name of the kind of problem, such as config/NotFound. It never changes, so code and people can rely on it.
  • Message (message): the sentence that tells a person what went wrong.
  • Hint (hint): optional advice on what to do about the issue.
  • Docs (docs): an optional link to more about the issue.
  • Wording: an issue's code, message, hint and docs together, the parts meant for people; wrap takes new wording for the issue it builds.
  • Value (T, value): the typed facts about the problem, for code, such as the path that was missing. An issue holds it only while unhandled.
  • Residue (R, residue): what handling yields, such as the config to use instead of the missing one. An issue holds it only once handled.
  • Cause: the issue that led to another. It is part of the value (a cause field of T), not a field of Issue; wrap builds a new issue whose value holds it, and render follows it.
  • Handle (handle): switch an unhandled issue to Handled(residue) directly, with no recovery. It settles Handled, or AlreadyHandled when the issue was handled before.
  • In-place switch: handling changes the issue itself, once, from Unhandled to Handled, and never back, so everyone holding the issue sees it.
  • Render (render): an issue as text for a person: its code and message, then its hint and docs, then each cause in its chain, once, up to a handled issue.

Issue state ​

  • Issue state (IssueState<T, R>): an immutable snapshot of an issue, Unhandled(value) or Handled(residue), read with state(). Handling gives the issue a new state and never changes an old one, so a narrowing on a snapshot stays true. It is structured like Option.
  • Unhandled (Unhandled(value)): the state of an issue no one has handled yet; it holds the value.
  • Handled (Handled(residue)): the state of an issue that has been handled; it holds the residue, and the value is gone. Handled also names an attempt variant.
  • Snapshot: what state() returns, an issue state that later handling leaves as it was. The issue's own isUnhandled and isHandled are plain booleans; the snapshot's are type guards.

Recoveries ​

  • Recovery (Recovery<T, R, E>): a typed repair, sync or async, that turns an issue's value into its residue: a Struct wrapping (value: T) => Vow<Outcome<R, E, unknown>>. Its type says which issues it fits, so it never declines one at runtime.
  • Repair: the function a recovery wraps, or the promise-returning one fromPromise takes, which does the work of handling.
  • Attempting (attempt): run a recovery on an issue's value and, if it succeeds while the issue is still unhandled, switch the issue in place. It settles a Vow of an Attempt, and settles at once for an issue already handled.
  • Recover with (recoverWith): attempt a recovery on the issue inside a Result's Err. An Ok passes through without running it.
  • Composition: or, orElse and firstOf try recoveries in order until one succeeds; retry runs one again after each failure; when runs one only for values that pass a test. Each stops at a Panicked outcome.

Attempts ​

  • Attempt (Attempt<R, E>): how attempting a recovery ended, one of four variants. It is covariant, like Result.
  • Handled (Handled(residue), the attempt variant): this attempt handled the issue, which switched in place to its residue.
  • AlreadyHandled (AlreadyHandled(residue)): the issue was handled before this attempt finished, so the recovery's own success or failure was not used (a panic still settles Panicked); it holds the residue the issue already had.
  • Failed (Failed(error)): the recovery failed with its error, and the issue stays unhandled.
  • Panicked (Panicked(payload)): the repair hit a bug, a panic; the issue stays unhandled, and every unwrap rethrows the payload.
  • Resolved (isResolved): either handled variant, AlreadyHandled or Handled.

Shared terms ​

These live in the root glossary: