mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-29 20:47:05 -05:00
Fix error boundary logging
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user