Appearance
@shbernal/ts-pptx / index / setDiagnosticHandler
Function: setDiagnosticHandler()
setDiagnosticHandler(
next):void
Defined in: src/diagnostics.ts:66
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 set the handler around each build.
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
next
DiagnosticHandler | null
the receiver, or null to restore the console default
Returns
void