Fix error boundary logging

This commit is contained in:
gpt-engineer-app[bot]
2025-11-04 18:58:03 +00:00
parent ded4dfd59c
commit 40529b17e2
5 changed files with 51 additions and 53 deletions

View File

@@ -3,7 +3,7 @@ import { AlertCircle, Home, RefreshCw } from 'lucide-react';
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { logger } from '@/lib/logger';
import { handleError } from '@/lib/errorHandler';
interface ErrorBoundaryProps {
children: ReactNode;
@@ -38,16 +38,13 @@ export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundarySt
}
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
// Generate error ID for user reference
const errorId = crypto.randomUUID();
// Log error with context
logger.error('Component error caught by boundary', {
context: this.props.context || 'unknown',
error: error.message,
stack: error.stack,
componentStack: errorInfo.componentStack,
errorId,
// Log to database and get error ID for user reference
const errorId = handleError(error, {
action: `Component error in ${this.props.context || 'unknown context'}`,
metadata: {
context: this.props.context,
componentStack: errorInfo.componentStack,
},
});
this.setState({ errorInfo, error: { ...error, errorId } as ErrorWithId });