From 9455a0a0a3447657fbb2f81b5e6b417c3a798049 Mon Sep 17 00:00:00 2001
From: gearnode
Date: Wed, 12 Feb 2025 08:57:24 -0800
Subject: [PATCH] Update style error boundary
Signed-off-by: gearnode
---
apps/console/src/App.tsx | 84 ++++++++++++++++---
apps/console/src/components/ErrorBoundary.tsx | 14 ++--
2 files changed, 80 insertions(+), 18 deletions(-)
diff --git a/apps/console/src/App.tsx b/apps/console/src/App.tsx
index 45534233f..237657395 100644
--- a/apps/console/src/App.tsx
+++ b/apps/console/src/App.tsx
@@ -7,6 +7,7 @@ import { RelayEnvironmentProvider } from "react-relay";
import { BrowserRouter, Route, Routes } from "react-router";
import "App.css";
import ErrorBoundary from "./components/ErrorBoundary";
+import { ErrorPage } from "./pages/ErrorPage";
import ConsoleLayout from "./layouts/ConsoleLayout";
import { RelayEnvironment } from "./RelayEnvironment";
@@ -30,23 +31,80 @@ const FrameworkOverviewPage = lazy(() => import("./pages/FrameworkOverviewPage")
function App() {
return (
- Something went wrong
}>
+
-
-
- }>
- } />
- } />
- } />
- } />
- } />
-
- } />
-
-
+
+
+
+
+ }
+ >
+
+
+
+
+
+ }
+ />
+
+
+
+
+
+ }
+ />
+
+
+
+
+
+ }
+ />
+
+
+
+
+
+ }
+ />
+
+
+
+
+
+ }
+ />
+
+
+
+ }
+ />
+
+
diff --git a/apps/console/src/components/ErrorBoundary.tsx b/apps/console/src/components/ErrorBoundary.tsx
index 795f6af75..65a2ce4f6 100644
--- a/apps/console/src/components/ErrorBoundary.tsx
+++ b/apps/console/src/components/ErrorBoundary.tsx
@@ -1,23 +1,24 @@
import { Component, ErrorInfo, ReactNode } from "react";
+import { ErrorPage } from "@/pages/ErrorPage";
interface ErrorBoundaryProps {
children: ReactNode;
- fallback: ReactNode;
+ fallback?: ReactNode;
}
interface ErrorBoundaryState {
hasError: boolean;
- error: Error | undefined;
+ error?: Error;
}
class ErrorBoundary extends Component {
constructor(props: ErrorBoundaryProps) {
super(props);
- this.state = { hasError: false, error: undefined };
+ this.state = { hasError: false };
}
static getDerivedStateFromError(error: Error): ErrorBoundaryState {
- return { hasError: true, error: error };
+ return { hasError: true, error };
}
componentDidCatch(error: Error, info: ErrorInfo): void {
@@ -27,7 +28,10 @@ class ErrorBoundary extends Component {
render(): ReactNode {
if (this.state.hasError) {
- return this.props.fallback;
+ if (this.props.fallback) {
+ return this.props.fallback;
+ }
+ return ;
}
return this.props.children;