Appearance
Function: setDiagnosticHandler() ​
setDiagnosticHandler(
next):void
Route every library diagnostic to handler, or pass null to restore the default (one prefixed console.warn per diagnostic).
This is process-global rather than per-presentation, deliberately: the emitting code is a tree of free functions in gen/** with no presentation in scope, and threading a handler through every signature would be a far larger and worse change than the problem warrants. The practical consequence is that a process building several decks concurrently cannot attribute a diagnostic to one of them. If that matters, correlate on code, or build the decks one at a time with the handler set around each build: a handler set around concurrent builds sees all of their diagnostics.
A throwing handler propagates out of whatever library call emitted the diagnostic, which is the supported way to make a specific condition fatal:
ts
setDiagnosticHandler((d) => {
if (d.code === 'coord/bare-number-is-inches') throw new Error(d.message)
})Parameters ​
| Parameter | Type | Description |
|---|---|---|
next | DiagnosticHandler | null | the receiver, or null to restore the console default |
Returns ​
void