Files
cozsweet-frontend-nextjs/src/app/global-error.tsx
T
admin 4083cf0b6c refactor: remove obsolete config and cross-layer exports
Drop the temporary static-generation retry override and stale hydration suppression. Refresh outdated Next.js and migration comments, and stop re-exporting Result through the storage layer.
2026-07-13 18:45:59 +08:00

62 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
/**
* 全局 Error Boundary
*
* global-error 必须是 Client Component,并自行提供 `<html>` 和 `<body>`
* 因为它会在根 layout 渲染失败时替换整个文档。
*/
import { ExceptionHandler } from "@/core/errors";
interface GlobalErrorProps {
error: Error & { digest?: string };
unstable_retry?: () => void;
}
export default function GlobalError({ error }: GlobalErrorProps) {
const errorMessage = ExceptionHandler.message(
error,
"An unexpected error occurred.",
);
return (
<html lang="en">
<body
style={{
fontFamily: "system-ui, sans-serif",
padding: "2rem",
background: "#111",
color: "#fff",
minHeight: "100vh",
}}
>
<h1 style={{ fontSize: "1.5rem", marginBottom: "1rem" }}>
Something went wrong
</h1>
<p style={{ marginBottom: "1rem", opacity: 0.8 }}>
{errorMessage}
</p>
<button
type="button"
onClick={() => {
window.location.href = "/";
}}
style={{
display: "inline-block",
padding: "0.5rem 1rem",
background: "#4f46e5",
color: "#fff",
borderRadius: "0.5rem",
border: 0,
cursor: "pointer",
fontSize: "1rem",
}}
>
Back to start
</button>
</body>
</html>
);
}