/** * Returns true if the error is a programming bug (TypeError, ReferenceError, * SyntaxError). Callers should re-throw these so they propagate to the global * error handler rather than being silently swallowed. */ export function isProgrammingError(error: unknown): boolean { return ( error instanceof TypeError || error instanceof ReferenceError || error instanceof SyntaxError ); } /** * Returns true if the error is an AppView network error (AppView unreachable). * Callers should return 503 so the user knows to retry. * * fetchApi() throws with this prefix for connection-level failures: * "AppView network error: ..." */ export function isNetworkError(error: unknown): boolean { return ( error instanceof Error && error.message.startsWith("AppView network error:") ); } /** * Returns true if the error is an AppView 404 Not Found response. * Callers should return a 404 HTML page to the user. * * fetchApi() throws with this prefix for non-ok HTTP responses: * "AppView API error: 404 Not Found" */ export function isNotFoundError(error: unknown): boolean { return ( error instanceof Error && error.message.startsWith("AppView API error: 404") ); }