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 bothTandR, since it changes in place. - Code (
code): the permanent, machine-readable name of the kind of problem, such asconfig/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;
wraptakes 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
causefield ofT), not a field ofIssue;wrapbuilds a new issue whose value holds it, andrenderfollows it. - Handle (
handle): switch an unhandled issue toHandled(residue)directly, with no recovery. It settlesHandled, orAlreadyHandledwhen the issue was handled before. - In-place switch: handling changes the issue itself, once, from
UnhandledtoHandled, 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)orHandled(residue), read withstate(). Handling gives the issue a new state and never changes an old one, so a narrowing on a snapshot stays true. It is structured likeOption. - 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.Handledalso names an attempt variant. - Snapshot: what
state()returns, an issue state that later handling leaves as it was. The issue's ownisUnhandledandisHandledare 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: aStructwrapping(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
fromPromisetakes, 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 aVowof anAttempt, and settles at once for an issue already handled. - Recover with (
recoverWith): attempt a recovery on the issue inside aResult'sErr. AnOkpasses through without running it. - Composition:
or,orElseandfirstOftry recoveries in order until one succeeds;retryruns one again after each failure;whenruns one only for values that pass a test. Each stops at aPanickedoutcome.
Attempts
- Attempt (
Attempt<R, E>): how attempting a recovery ended, one of four variants. It is covariant, likeResult. - 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 settlesPanicked); 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,AlreadyHandledorHandled.
Shared terms
These live in the root glossary:
- Panic, and the panic boundary
fromPromiseruns its repair under - Outcome, what a recovery settles
- Vow, what
attempt,runandrecoverWithreturn - main/mini, the two forms of each feature