Skip to content

rethrowIfInvariant ​

rethrowIfInvariant ​

Rethrows error if it is an invariant/programmer error (TypeError, RangeError, ReferenceError, SyntaxError); otherwise returns.

Boundary wrappers that turn an expected failure into a Result should call this first, so a genuine crash is never masked as a clean parse/decode failure.

ts
function rethrowIfInvariant(
	error: unknown,
): void

Parameters

  • error: unknown

Released under the MIT License.