mc-dashboard/app/error.tsx

40 lines
1.1 KiB
TypeScript
Raw Normal View History

2026-04-13 05:30:23 -06:00
"use client";
import { useEffect } from "react";
import Link from "next/link";
import { Button } from "@/components/ui/button";
export default function GlobalError({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) {
useEffect(() => {
console.error("App error:", error);
}, [error]);
return (
<div className="flex-1 flex items-center justify-center p-6">
<div className="max-w-md text-center space-y-4">
<h1 className="text-2xl font-bold tracking-tight">Something went wrong</h1>
<p className="text-sm text-muted-foreground break-words">
{error.message || "An unexpected error occurred."}
</p>
{error.digest && (
<p className="text-xs text-muted-foreground/60 font-mono">
ref: {error.digest}
</p>
)}
<div className="flex gap-2 justify-center pt-2">
<Button onClick={reset}>Try again</Button>
<Button variant="ghost" render={<Link href="/" />}>
Home
</Button>
</div>
</div>
</div>
);
}