WIP! A BB-style forum, on the ATmosphere! We're still working... we'll be back soon when we have something to show off!
node typescript hono htmx atproto
at f53be90536e6445b2c17faf0d219937abc94a3d4 40 lines 1.2 kB view raw
1/** 2 * Returns true if the error is a programming bug (TypeError, ReferenceError, 3 * SyntaxError). Callers should re-throw these so they propagate to the global 4 * error handler rather than being silently swallowed. 5 */ 6export function isProgrammingError(error: unknown): boolean { 7 return ( 8 error instanceof TypeError || 9 error instanceof ReferenceError || 10 error instanceof SyntaxError 11 ); 12} 13 14/** 15 * Returns true if the error is an AppView network error (AppView unreachable). 16 * Callers should return 503 so the user knows to retry. 17 * 18 * fetchApi() throws with this prefix for connection-level failures: 19 * "AppView network error: ..." 20 */ 21export function isNetworkError(error: unknown): boolean { 22 return ( 23 error instanceof Error && 24 error.message.startsWith("AppView network error:") 25 ); 26} 27 28/** 29 * Returns true if the error is an AppView 404 Not Found response. 30 * Callers should return a 404 HTML page to the user. 31 * 32 * fetchApi() throws with this prefix for non-ok HTTP responses: 33 * "AppView API error: 404 Not Found" 34 */ 35export function isNotFoundError(error: unknown): boolean { 36 return ( 37 error instanceof Error && 38 error.message.startsWith("AppView API error: 404") 39 ); 40}