diff --git a/src/components/base/base-error-boundary.tsx b/src/components/base/base-error-boundary.tsx index 3c04508ffbd9055df15457b1192a2a26c3fd766e..2475a2ffdff3aba17391c6785083e0592d77009f 100644 --- a/src/components/base/base-error-boundary.tsx +++ b/src/components/base/base-error-boundary.tsx @@ -3,18 +3,24 @@ import { ErrorBoundary, FallbackProps } from "react-error-boundary"; function ErrorFallback({ error }: FallbackProps) { return ( - <div role="alert"> - <p>Something went wrong:(</p> + <div role="alert" style={{ padding: 16 }}> + <h4>Something went wrong:(</h4> + <pre>{error.message}</pre> + + <details title="Error Stack"> + <summary>Error Stack</summary> + <pre>{error.stack}</pre> + </details> </div> ); } -interface BaseErrorBoundaryProps { +interface Props { children?: ReactNode; } -export const BaseErrorBoundary: React.FC<BaseErrorBoundaryProps> = (props) => { +export const BaseErrorBoundary = (props: Props) => { return ( <ErrorBoundary FallbackComponent={ErrorFallback}> {props.children} diff --git a/src/main.tsx b/src/main.tsx index 0b0cf98f1878ef650ee16f4135330090556070b9..8588844ed47934f2cc519a868488447c1f8a2562 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -11,6 +11,7 @@ import React from "react"; import { createRoot } from "react-dom/client"; import { RecoilRoot } from "recoil"; import { BrowserRouter } from "react-router-dom"; +import { BaseErrorBoundary } from "./components/base"; import Layout from "./pages/_layout"; import "./services/i18n"; @@ -26,9 +27,11 @@ if (!container) { createRoot(container).render( <React.StrictMode> <RecoilRoot> - <BrowserRouter> - <Layout /> - </BrowserRouter> + <BaseErrorBoundary> + <BrowserRouter> + <Layout /> + </BrowserRouter> + </BaseErrorBoundary> </RecoilRoot> </React.StrictMode> );