()
| 40 | |
| 41 | /** Install global handlers. Call once at app startup. */ |
| 42 | export function installGlobalErrorReporting(): void { |
| 43 | window.addEventListener('error', (e) => { |
| 44 | reportError(e.message || String(e.error), e.error?.stack) |
| 45 | }) |
| 46 | window.addEventListener('unhandledrejection', (e) => { |
| 47 | const reason = e.reason |
| 48 | reportError( |
| 49 | reason instanceof Error ? reason.message : `Unhandled rejection: ${String(reason)}`, |
| 50 | reason instanceof Error ? reason.stack : undefined |
| 51 | ) |
| 52 | }) |
| 53 | } |