🌳
pt0/sharedF/throwErrorF/throwIfF.mts
1import { throPtErr } from './sharedErrF.mts'
3// context is a debugH object, not a string message
4export const throwIf = (conditionFn: () => unknown, context?: Record<string, unknown>) => {
5 const result = conditionFn()
6 if (result) {
7 const fnString = conditionFn.toString()
8 const expression = fnString.substring(fnString.indexOf('=>') + 2).trim()
9 throPtErr(expression, context)
10 }