Changed error boundary to cover both full hub and disaptch app

This commit is contained in:
PxlLoewe
2025-05-29 22:25:30 -07:00
parent d968507484
commit 0cebe2b97e
24 changed files with 226 additions and 194 deletions

View File

@@ -0,0 +1,29 @@
"use client";
import { ErrorBoundary } from "react-error-boundary";
import { Error as ErrorComp } from "./Error";
export const CustomErrorBoundary = ({ children }: { children?: React.ReactNode }) => {
return (
<ErrorBoundary
fallbackRender={({ error }) => {
console.log(error);
let errorTest;
let errorCode = 500;
if ("statusCode" in error) {
errorCode = (error as any).statusCode;
}
if ("message" in error || error instanceof Error) {
errorTest = (error as any).message;
} else if (typeof error === "string") {
errorTest = error;
} else {
errorTest = "Ein unerwarteter Fehler ist aufgetreten.";
}
return <ErrorComp title={errorTest} statusCode={errorCode} />;
}}
>
{children}
</ErrorBoundary>
);
};