/** * Returns true for errors that indicate a programming bug rather than a * runtime failure (network down, DB unavailable, bad user input, etc.). * * These should NOT be caught and swallowed — re-throw them so they surface * clearly during development instead of being silently logged. * * - TypeError: accessing a property on null/undefined, calling a non-function * - ReferenceError: using an undeclared variable * - SyntaxError: malformed JSON.parse in our own code */ export function isProgrammingError(error: unknown): boolean { return ( error instanceof TypeError || error instanceof ReferenceError || error instanceof SyntaxError ); }