Skip to main content
Version: v0.0.4

Variable: SYNTH_FATAL_MESSAGES

const SYNTH_FATAL_MESSAGES: Readonly<Record<SynthFatalCode, string>>

The frozen message registry - the only place a SynthError message can come from.

A message here is a fixed string. It never quotes the request that produced it, and there is no parameter through which it could: SynthError takes a code and nothing else. That is the whole mechanism, and it is deliberately a mechanism rather than a habit. Every one of these messages used to be assembled by interpolating the caller's value into a template, and the reason that was safe was not the design - it was that the caller happened to be passing a quirk name.

The trade is real and is accepted: a fatal no longer tells you which value it rejected. It tells you which rule refused, on err.code, and the stack frame tells you where. The caller already holds the value it passed.

Example

import { SYNTH_FATAL_CODES, SYNTH_FATAL_MESSAGES } from "@cosyte/synth";
SYNTH_FATAL_MESSAGES[SYNTH_FATAL_CODES.SYNTH_EMPTY_POOL]; // => "A value was drawn from an empty pool."