Files
mintel.me/apps/web/app/[locale]/error.tsx
T
mmintelandClaude Opus 5.5 75993100fa feat: German as the main language, English under /en, with a language switch
The site now exists in German (at the root, with /impressum and /datenschutz)
and English (/en). A request without a language follows the visitor's choice
from the language switch, then the browser language, then German; the old
English legal addresses move to /en for good.

All visible texts are data in src/content/de.ts and en.ts, so components hold
none of their own. The header carries a DE/EN switch whose bit curtain covers
the page while it is swapped and reopens at the same reading position. Title,
description, canonical, hreflang, Open Graph, the share image, the sitemap and
the structured data are per language. The privacy notice now describes the
cookie that remembers the chosen language.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:07:22 +02:00

88 lines
3.2 KiB
TypeScript

"use client";
import { useEffect } from "react";
import * as Sentry from "@sentry/nextjs";
import { Button } from "@/src/components/Button";
import { useContent, useLocale } from "@/src/components/ContentProvider";
import { pathFor } from "@/src/domain/routes";
export default function Error({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) {
const { error: copy } = useContent();
const home = pathFor("home", useLocale());
useEffect(() => {
// Log the error to Sentry/GlitchTip
Sentry.captureException(error);
console.error("Caught in error.tsx:", error);
// Auto-reload on ChunkLoadError or Server Action errors to fetch the new deployment assets
const isChunkLoadError =
error.message &&
(error.message.includes("ChunkLoadError") ||
error.message.includes("Loading chunk") ||
error.message.includes("Failed to find Server Action"));
if (isChunkLoadError) {
const lastReload = sessionStorage.getItem("last-chunk-reload");
const now = Date.now();
if (!lastReload || now - parseInt(lastReload) > 10000) {
sessionStorage.setItem("last-chunk-reload", now.toString());
window.location.reload();
}
}
}, [error]);
return (
<div className="flex flex-col items-center justify-center min-h-[70vh] px-5 py-20 text-center">
<div className="space-y-6 max-w-2xl mx-auto">
<span className="inline-block px-3 py-1 bg-red-50 border border-red-100 rounded text-[10px] font-mono text-red-500 uppercase tracking-widest">
{copy.kicker}
</span>
<h1 className="text-5xl md:text-7xl font-black text-slate-900 tracking-tighter">
{copy.title}
</h1>
<p className="text-xl md:text-2xl text-slate-500 font-serif italic max-w-xl mx-auto leading-relaxed">
{copy.text}
</p>
<div className="pt-8 flex flex-col sm:flex-row items-center justify-center gap-4">
<Button href="#" onClick={() => reset()} variant="primary">
{copy.retry}
</Button>
<Button href={home} variant="outline">
{copy.home}
</Button>
</div>
<div className="pt-16 max-w-sm mx-auto">
<div className="bg-slate-50 p-6 rounded-2xl border border-slate-100 text-left font-mono text-xs text-slate-400">
<div className="flex items-center justify-between border-b border-slate-200/60 pb-2 mb-2">
<span>STATUS</span>
<span className="text-red-500 flex items-center gap-2">
<span className="w-1.5 h-1.5 rounded-full bg-red-500 animate-pulse"></span>
FAIL
</span>
</div>
<div className="flex justify-between border-b border-slate-200/60 pb-2 mb-2">
<span>TRACKING</span>
<span className="text-green-500">GLITCHTIP_LOGGED</span>
</div>
{error.digest && (
<div className="flex justify-between">
<span>DIGEST</span>
<span className="truncate max-w-[150px]">{error.digest}</span>
</div>
)}
</div>
</div>
</div>
</div>
);
}