Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021// Safe display messages for arbitrary thrown values.export function errMessage(e: unknown): string { if (e instanceof Error) return e.message; if (typeof e === 'string') return e; try { return JSON.stringify(e); } catch { return String(e); }}
// Extract an HTTP status code from an error if one was attached via// `Object.assign(new Error(...), { statusCode: 4xx })`, else 500.export function errStatus(e: unknown): number { if (e && typeof e === 'object' && 'statusCode' in e) { const code = (e as { statusCode: unknown }).statusCode; if (typeof code === 'number' && code >= 400 && code < 600) return code; } return 500;}