error.tsx68 lines · main
| 1 | 'use client'; |
| 2 | |
| 3 | import Link from 'next/link'; |
| 4 | import { useEffect } from 'react'; |
| 5 | |
| 6 | /** |
| 7 | * Segment-level error boundary (500 / unexpected runtime errors). Rendered |
| 8 | * inside the root layout, so globals.css + fonts apply. Uses a plain <img> |
| 9 | * (not next/image) so the fallback stays robust even when something is broken. |
| 10 | */ |
| 11 | export default function Error({ |
| 12 | error, |
| 13 | reset, |
| 14 | }: { |
| 15 | error: Error & { digest?: string }; |
| 16 | reset: () => void; |
| 17 | }) { |
| 18 | useEffect(() => { |
| 19 | // the real stack is captured server-side; surface the digest for support. |
| 20 | console.error(error); |
| 21 | }, [error]); |
| 22 | |
| 23 | return ( |
| 24 | <main className="mx-auto flex min-h-dvh max-w-2xl flex-col justify-center gap-6 px-6 py-16 font-mono text-sm"> |
| 25 | <Link href="/" className="flex items-center gap-2" aria-label="briven home"> |
| 26 | <img src="/icon.svg" alt="" width={28} height={28} /> |
| 27 | <span>briven</span> |
| 28 | </Link> |
| 29 | |
| 30 | <div> |
| 31 | <h1 className="text-2xl tracking-tight">500 · something broke</h1> |
| 32 | <p className="mt-2 text-[var(--color-text-muted)]"> |
| 33 | an unexpected error happened on our side. it's logged — give it another try, or head |
| 34 | back home. |
| 35 | </p> |
| 36 | {error.digest ? ( |
| 37 | <p className="mt-2 text-[10px] text-[var(--color-text-subtle)]">reference: {error.digest}</p> |
| 38 | ) : null} |
| 39 | </div> |
| 40 | |
| 41 | <div className="flex flex-wrap gap-2"> |
| 42 | <button |
| 43 | type="button" |
| 44 | onClick={reset} |
| 45 | className="rounded-md border border-[var(--color-border-subtle)] bg-[var(--color-surface)] px-4 py-3 hover:border-[var(--color-border)]" |
| 46 | > |
| 47 | ↻ try again |
| 48 | </button> |
| 49 | <Link |
| 50 | href="/" |
| 51 | className="rounded-md border border-[var(--color-border-subtle)] bg-[var(--color-surface)] px-4 py-3 hover:border-[var(--color-border)]" |
| 52 | > |
| 53 | go home → |
| 54 | </Link> |
| 55 | <Link |
| 56 | href="https://docs.briven.tech/status" |
| 57 | className="rounded-md border border-[var(--color-border-subtle)] bg-[var(--color-surface)] px-4 py-3 hover:border-[var(--color-border)]" |
| 58 | > |
| 59 | check status → |
| 60 | </Link> |
| 61 | </div> |
| 62 | |
| 63 | <footer className="mt-auto pt-8 font-mono text-[10px] text-[var(--color-text-subtle)]"> |
| 64 | built with <span className="text-[#e8344a]">♥</span> in Flanders · flndrn Limited |
| 65 | </footer> |
| 66 | </main> |
| 67 | ); |
| 68 | } |