mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 20:11:14 -05:00
Fix error boundary logging
This commit is contained in:
@@ -3,7 +3,7 @@ import { AlertCircle, ArrowLeft, RefreshCw, Shield } 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 AdminErrorBoundaryProps {
|
||||
children: ReactNode;
|
||||
@@ -50,16 +50,14 @@ export class AdminErrorBoundary extends Component<AdminErrorBoundaryProps, Admin
|
||||
}
|
||||
|
||||
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
||||
// Generate error ID for user reference
|
||||
const errorId = crypto.randomUUID();
|
||||
|
||||
logger.error('Admin panel error caught by boundary', {
|
||||
section: this.props.section || 'unknown',
|
||||
error: error.message,
|
||||
stack: error.stack,
|
||||
componentStack: errorInfo.componentStack,
|
||||
severity: 'high', // Admin errors are high priority
|
||||
errorId,
|
||||
// Log to database and get error ID for user reference
|
||||
const errorId = handleError(error, {
|
||||
action: `Admin panel error in ${this.props.section || 'unknown section'}`,
|
||||
metadata: {
|
||||
section: this.props.section,
|
||||
componentStack: errorInfo.componentStack,
|
||||
severity: 'high',
|
||||
},
|
||||
});
|
||||
|
||||
this.setState({ errorInfo, error: { ...error, errorId } as ErrorWithId });
|
||||
|
||||
@@ -3,7 +3,7 @@ import { AlertCircle, ArrowLeft, 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 EntityErrorBoundaryProps {
|
||||
children: ReactNode;
|
||||
@@ -38,16 +38,14 @@ export class EntityErrorBoundary extends Component<EntityErrorBoundaryProps, Ent
|
||||
}
|
||||
|
||||
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
||||
// Generate error ID for user reference
|
||||
const errorId = crypto.randomUUID();
|
||||
|
||||
logger.error('Entity page error caught by boundary', {
|
||||
entityType: this.props.entityType,
|
||||
entitySlug: this.props.entitySlug,
|
||||
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: `${this.props.entityType} page error`,
|
||||
metadata: {
|
||||
entityType: this.props.entityType,
|
||||
entitySlug: this.props.entitySlug,
|
||||
componentStack: errorInfo.componentStack,
|
||||
},
|
||||
});
|
||||
|
||||
this.setState({ errorInfo, error: { ...error, errorId } as ErrorWithId });
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -3,7 +3,7 @@ import { AlertCircle, RefreshCw } from 'lucide-react';
|
||||
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { logger } from '@/lib/logger';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
|
||||
interface ModerationErrorBoundaryProps {
|
||||
children: ReactNode;
|
||||
@@ -18,6 +18,8 @@ interface ModerationErrorBoundaryState {
|
||||
errorInfo: ErrorInfo | null;
|
||||
}
|
||||
|
||||
type ErrorWithId = Error & { errorId: string };
|
||||
|
||||
/**
|
||||
* Error Boundary for Moderation Queue Components
|
||||
*
|
||||
@@ -52,17 +54,18 @@ export class ModerationErrorBoundary extends Component<
|
||||
}
|
||||
|
||||
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
||||
// Log error to monitoring system
|
||||
logger.error('Moderation component error caught by boundary', {
|
||||
action: 'error_boundary_catch',
|
||||
submissionId: this.props.submissionId,
|
||||
error: error.message,
|
||||
stack: error.stack,
|
||||
componentStack: errorInfo.componentStack,
|
||||
// Log to database and get error ID for user reference
|
||||
const errorId = handleError(error, {
|
||||
action: 'Moderation queue item render error',
|
||||
metadata: {
|
||||
submissionId: this.props.submissionId,
|
||||
componentStack: errorInfo.componentStack,
|
||||
},
|
||||
});
|
||||
|
||||
// Update state with error info
|
||||
this.setState({
|
||||
error: { ...error, errorId } as ErrorWithId,
|
||||
errorInfo,
|
||||
});
|
||||
|
||||
@@ -103,6 +106,11 @@ export class ModerationErrorBoundary extends Component<
|
||||
<p className="text-sm">
|
||||
{this.state.error?.message || 'An unexpected error occurred'}
|
||||
</p>
|
||||
{(this.state.error as ErrorWithId)?.errorId && (
|
||||
<p className="text-xs font-mono bg-destructive/10 px-2 py-1 rounded">
|
||||
Reference ID: {(this.state.error as ErrorWithId).errorId.slice(0, 8)}
|
||||
</p>
|
||||
)}
|
||||
{this.props.submissionId && (
|
||||
<p className="text-xs text-muted-foreground font-mono">
|
||||
Submission ID: {this.props.submissionId}
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { Component, ErrorInfo, ReactNode } from 'react';
|
||||
import { AlertTriangle, Home, RefreshCw } from 'lucide-react';
|
||||
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 RouteErrorBoundaryProps {
|
||||
children: ReactNode;
|
||||
@@ -32,17 +32,14 @@ export class RouteErrorBoundary extends Component<RouteErrorBoundaryProps, Route
|
||||
}
|
||||
|
||||
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
||||
// Generate error ID for user reference
|
||||
const errorId = crypto.randomUUID();
|
||||
|
||||
// Critical: Route-level error - highest priority logging
|
||||
logger.error('Route-level error caught by boundary', {
|
||||
error: error.message,
|
||||
stack: error.stack,
|
||||
componentStack: errorInfo.componentStack,
|
||||
url: window.location.href,
|
||||
severity: 'critical',
|
||||
errorId,
|
||||
// Log to database and get error ID for user reference
|
||||
const errorId = handleError(error, {
|
||||
action: 'Route-level component crash',
|
||||
metadata: {
|
||||
componentStack: errorInfo.componentStack,
|
||||
url: window.location.href,
|
||||
severity: 'critical',
|
||||
},
|
||||
});
|
||||
|
||||
this.setState({ error: { ...error, errorId } as ErrorWithId });
|
||||
|
||||
Reference in New Issue
Block a user