Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import PrefetchingEngine from '@/components/performance/PrefetchingEngine';
import StateManagerIntegration from '@/components/state/StateManagerIntegration';
import { PWAManager } from '@/components/pwa/PWAManager';
import { AccessibilityProvider } from '@/components/accessibility/AccessibilityProvider';
import { ErrorBoundary } from '@/components/errors/ErrorBoundarySystem';

const geistSans = Geist({
// ...
Expand Down Expand Up @@ -79,7 +80,9 @@ export default function RootLayout({
<StateManagerIntegration />
<PerformanceMonitor />
<PrefetchingEngine />
{children}
<ErrorBoundary>
{children}
</ErrorBoundary>
</OfflineModeProvider>
</PerformanceMonitoringProvider>
</AccessibilityProvider>
Expand Down
25 changes: 17 additions & 8 deletions src/components/errors/ErrorBoundarySystem.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
'use client';

import React, { Component, ReactNode, ErrorInfo } from 'react';
import { errorReportingService } from '@/services/errorReporting';
import { UserFriendlyErrorDisplay } from './UserFriendlyErrorDisplay';

type ErrorBoundaryState = {
hasError: boolean;
error: Error | null;
errorInfo?: ErrorInfo;
errorCount: number;
};

type ErrorBoundaryProps = {
children: ReactNode;
fallback?: ReactNode;
onError?: (error: Error, errorInfo: ErrorInfo) => void;
isolationId?: string;
isolationLevel?: string;
};

export class ErrorBoundarySystem extends Component<
Expand All @@ -23,6 +29,8 @@ export class ErrorBoundarySystem extends Component<
this.state = {
hasError: false,
error: null,
errorInfo: undefined,
errorCount: 0,
};
}

Expand Down Expand Up @@ -58,21 +66,22 @@ export class ErrorBoundarySystem extends Component<
this.setState({
hasError: false,
error: null,
errorInfo: undefined,
errorCount: 0,
});
};

render() {
if (this.state.hasError) {
return (
this.props.fallback || (
<div style={{ padding: '20px' }}>
<h2>Something went wrong.</h2>
<p>{this.state.error?.message}</p>

<button onClick={this.resetError}>
Try Again
</button>
</div>
<UserFriendlyErrorDisplay
error={this.state.error}
title="Application Error"
onRetry={this.resetError}
showDetails={true}
severity="error"
/>
)
);
}
Expand Down
Loading