Files
jmap-webmail/lib/error-reporting.ts
T
Matthieu MALVACHE 81ec4cb471 feat: Add error boundaries and real-time push notifications
- Implement error boundaries with graceful fallbacks for all major components
  (sidebar, email list, email viewer, composer)
- Add push notifications via EventSource for real-time email updates
- Show connection status indicator in sidebar footer
- Play notification sound and show toast for new emails
- Add global error handler and error reporting utilities
- Configure ESLint with modern flat config
- Various fixes: unused variable warnings, proper cleanup on disconnect
- Update translations for error messages (EN/FR)
2025-12-10 00:43:46 +01:00

44 lines
1.1 KiB
TypeScript

import { debug } from "./debug";
interface ErrorReport {
error: Error;
errorInfo?: React.ErrorInfo;
zone: string;
timestamp: Date;
userAgent: string;
url: string;
}
/**
* Report an error to the logging system.
* In debug mode, logs detailed information to the console.
* Future: Can be extended to send to external error tracking services.
*/
export function reportError(
error: Error,
zone: string,
errorInfo?: React.ErrorInfo
): void {
const report: ErrorReport = {
error,
errorInfo,
zone,
timestamp: new Date(),
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : "SSR",
url: typeof window !== "undefined" ? window.location.href : "",
};
// Always log errors
debug.error(`[ErrorBoundary:${zone}]`, error.message, {
stack: error.stack,
componentStack: errorInfo?.componentStack,
url: report.url,
timestamp: report.timestamp.toISOString(),
});
// Future: Send to error tracking service (Sentry, etc.)
// if (process.env.NODE_ENV === 'production') {
// sendToErrorService(report);
// }
}