import { useNavigate } from "@solidjs/router"; import { createSignal } from "solid-js"; import { TerminalErrorPage } from "~/components/TerminalErrorPage"; import { useDarkMode } from "~/context/darkMode"; export interface ErrorBoundaryFallbackProps { error: Error; reset: () => void; } export default function ErrorBoundaryFallback( props: ErrorBoundaryFallbackProps ) { let navigate: ((path: string) => void) | undefined; try { navigate = useNavigate(); } catch (e) { navigate = (path: string) => { window.location.href = path; }; } let isDark: () => boolean; try { const darkMode = useDarkMode(); isDark = darkMode.isDark; } catch (e) { isDark = () => true; } const [glitchText, setGlitchText] = createSignal("ERROR"); console.error(props.error); const errorContent = (
fatal: Unhandled Runtime Exception
✗
{glitchText()}
Application encountered an unexpected error
{props.error.message && (
Message:
{props.error.message}
)} {props.error.stack && (
Stack trace:
{props.error.stack}
)}
ℹ Type help to see available commands, or try one of the suggestions below
); const quickActions = (
Quick actions:
); return ( ?~`"} glitchSpeed={150} glitchThreshold={0.8} glitchIntensity={0.6} navigate={navigate!} location={{ pathname: typeof window !== "undefined" ? window.location.pathname : "/" }} errorContent={errorContent} quickActions={quickActions} footer={ <> ERR |{" "} Runtime Exception } onGlitchTextChange={setGlitchText} commandContext={{ isDark }} /> ); }