Skip to content

Commit 1472dcc

Browse files
committed
Added global error boundary wrapper.
1 parent 200aa20 commit 1472dcc

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/app/layout.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import 'animate.css/animate.min.css'
77
import { LayoutTransition } from '@/components/layout/layout-transition'
88
import Script from 'next/script'
99
import Footer from '../components/layout/footer'
10+
// Import the components we created
11+
import ErrorBoundary from '@/components/ErrorBoundary'
12+
import GlobalErrorHandler from '@/components/GlobalErrorHandler'
1013

1114
export const metadata: Metadata = {
1215
title: 'CodeBuilder, Inc. - Software Engineering Solutions.',
@@ -57,6 +60,11 @@ export default function RootLayout({
5760
{/* Other Meta Tags, Links, Etc... */}
5861
</head>
5962
<body className={`${Raleway.className} antialiased bg-white`}>
63+
{/*
64+
The GlobalErrorHandler is an invisible component that sets up
65+
window-level event listeners for catching uncaught errors.
66+
*/}
67+
<GlobalErrorHandler />
6068
<div className="flex flex-col min-h-screen">
6169
<Header />
6270
<LayoutTransition
@@ -68,7 +76,13 @@ export default function RootLayout({
6876
{/* Main content area */}
6977
<main className="flex text-black bg-white">
7078
{' '}
71-
<div className="w-screen">{children}</div>
79+
{/*
80+
The ErrorBoundary wraps your entire application. It will catch
81+
any rendering errors and display a fallback UI instead of crashing.
82+
*/}
83+
<ErrorBoundary>
84+
<div className="w-screen">{children}</div>
85+
</ErrorBoundary>
7286
</main>
7387
{/* Footer */}
7488
<Footer />

0 commit comments

Comments
 (0)