Skip to content

Commit bdeffa6

Browse files
committed
feat(web): add application error boundary to main layout
Wrap RouterProvider with ErrorBoundary component to prevent application crashes: - Added ErrorBoundary import to main.tsx - Configured with retry capability and development details display - Enhanced error reporting with structured logging - Provides graceful error recovery for unhandled component errors Improves application stability and user experience during failures.
1 parent 4fba706 commit bdeffa6

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

apps/web/src/main.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import posthog from "posthog-js";
1414
import { createRoot } from "react-dom/client";
1515

1616
import { PostHogProvider } from "@/components/PostHogProvider";
17+
import { ErrorBoundary } from "@/components/ui/ErrorBoundary";
1718
import { StorageProviderWrapper } from "@/contexts/storage-provider-context";
1819
import { ThemeProvider } from "@/contexts/theme-context";
1920
import { AppActivityProvider } from "@/stores/app-activity-store";
@@ -348,7 +349,22 @@ createRoot(rootElement, reactErrorHandlers).render(
348349
<StorageProviderWrapper provider={storageProvider}>
349350
<LayoutProvider>
350351
<AppActivityProvider>
351-
<RouterProvider router={router} />
352+
<ErrorBoundary
353+
title="Application Error"
354+
description="Something went wrong while loading the application. Please try again."
355+
showRetry={true}
356+
showDetails={process.env.NODE_ENV === 'development'}
357+
onError={(error, errorInfo, errorId) => {
358+
logger.error('main', 'Application error caught by ErrorBoundary', {
359+
errorId,
360+
error: error.message,
361+
stack: error.stack,
362+
componentStack: errorInfo?.componentStack,
363+
});
364+
}}
365+
>
366+
<RouterProvider router={router} />
367+
</ErrorBoundary>
352368
</AppActivityProvider>
353369
</LayoutProvider>
354370
</StorageProviderWrapper>

0 commit comments

Comments
 (0)