gendesign/tradein-mvp/frontend/src/app/error.tsx
lekss361 3665a61e48
All checks were successful
Deploy Trade-In / changes (push) Successful in 5s
Deploy Trade-In / build-backend (push) Has been skipped
Deploy Trade-In / build-frontend (push) Successful in 1m24s
Deploy Trade-In / deploy (push) Successful in 32s
fix(tradein-frontend): safeUrl validator, apiFetch dedup, ListingsCard a11y, error boundary (#512)
2026-05-24 11:47:38 +00:00

55 lines
1.7 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";
/**
* App Router error boundary for the trade-in page (Next 15 idiom).
*
* Triggers when a component below `app/page.tsx` throws during render or
* inside an Effect. Without this, the page would white-screen. Closes
* finding #16 from 2026-05-24 trade-in audit.
*/
import { useEffect } from "react";
interface Props {
error: Error & { digest?: string };
reset: () => void;
}
export default function Error({ error, reset }: Props) {
useEffect(() => {
// Surfaces to browser devtools + (if wired) Sentry.
console.error("trade-in page error:", error);
}, [error]);
return (
<main className="page" role="alert" style={{ padding: "32px 16px", maxWidth: 600, margin: "0 auto" }}>
<h1 style={{ marginBottom: 12, fontSize: 20, fontWeight: 600 }}>
Что-то пошло не так
</h1>
<p style={{ color: "var(--muted)", marginBottom: 16, lineHeight: 1.5 }}>
Произошла ошибка при отображении страницы. Можно попробовать ещё раз
если повторяется, перезагрузите страницу.
</p>
{error.digest && (
<p style={{ color: "var(--muted-2)", fontSize: 12, marginBottom: 16, fontFamily: "monospace" }}>
ID ошибки: {error.digest}
</p>
)}
<button
type="button"
onClick={reset}
style={{
padding: "10px 16px",
background: "var(--accent)",
color: "white",
border: "none",
borderRadius: 6,
fontSize: 14,
fontWeight: 500,
cursor: "pointer",
}}
>
Попробовать ещё раз
</button>
</main>
);
}