mirror of
https://github.com/root-fr/jmap-webmail.git
synced 2026-09-23 16:01:15 +00:00
- 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)
44 lines
1.1 KiB
TypeScript
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);
|
|
// }
|
|
}
|