import { useNavigate } from "@solidjs/router"; import { createSignal, For, onMount, onCleanup } from "solid-js"; export interface ErrorBoundaryFallbackProps { error: Error; reset: () => void; } export default function ErrorBoundaryFallback( props: ErrorBoundaryFallbackProps ) { // Try to get navigate, but handle case where we're outside router context let navigate: ((path: string) => void) | undefined; try { navigate = useNavigate(); } catch (e) { // If we're outside router context, fallback to window.location navigate = (path: string) => { window.location.href = path; }; } const [glitchText, setGlitchText] = createSignal("ERROR"); // Log error immediately (safe for SSR) console.error(props.error); // Client-only glitch animation onMount(() => { const glitchChars = "!@#$%^&*()_+-=[]{}|;':\",./<>?~`"; const originalText = "ERROR"; const glitchInterval = setInterval(() => { if (Math.random() > 0.8) { let glitched = ""; for (let i = 0; i < originalText.length; i++) { if (Math.random() > 0.6) { glitched += glitchChars[Math.floor(Math.random() * glitchChars.length)]; } else { glitched += originalText[i]; } } setGlitchText(glitched); setTimeout(() => setGlitchText(originalText), 150); } }, 400); onCleanup(() => clearInterval(glitchInterval)); }); const createParticles = () => { return Array.from({ length: 40 }, (_, i) => ({ id: i, left: `${Math.random() * 100}%`, top: `${Math.random() * 100}%`, animationDelay: `${Math.random() * 3}s`, animationDuration: `${2 + Math.random() * 3}s` })); }; return (
An unexpected error has disrupted the flow of ... something.
But don't worry, you can try again or navigate back to safety.
Error: {props.error.message}
)}System Error • Something went wrong