debug: add try-catch to catch db errors on main page
This commit is contained in:
17
app/page.tsx
17
app/page.tsx
@@ -4,6 +4,7 @@ import MenuView from "./components/MenuView";
|
|||||||
export const dynamic = 'force-dynamic';
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
|
try {
|
||||||
const restaurant = await prisma.restaurant.findFirst({
|
const restaurant = await prisma.restaurant.findFirst({
|
||||||
include: {
|
include: {
|
||||||
categories: {
|
categories: {
|
||||||
@@ -37,7 +38,7 @@ export default async function Page() {
|
|||||||
id: cat.id,
|
id: cat.id,
|
||||||
title: cat.title,
|
title: cat.title,
|
||||||
externalId: cat.externalId,
|
externalId: cat.externalId,
|
||||||
items: cat.items.map(item => ({
|
items: (cat.items || []).map(item => ({
|
||||||
name: item.name,
|
name: item.name,
|
||||||
ingredients: item.ingredients,
|
ingredients: item.ingredients,
|
||||||
tasteProfile: item.tasteProfile,
|
tasteProfile: item.tasteProfile,
|
||||||
@@ -48,4 +49,18 @@ export default async function Page() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return <MenuView data={data} />;
|
return <MenuView data={data} />;
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error("Database error:", error);
|
||||||
|
return (
|
||||||
|
<div style={{ background: '#000', color: '#fff', height: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center', textAlign: 'center', padding: '20px' }}>
|
||||||
|
<div>
|
||||||
|
<h1 style={{ color: 'var(--gold)' }}>LUNA</h1>
|
||||||
|
<p>Veritabanı bağlantısı sırasında bir hata oluştu.</p>
|
||||||
|
<pre style={{ fontSize: '0.7rem', color: '#ff4d4d', marginTop: '10px', overflowX: 'auto', maxWidth: '80vw' }}>
|
||||||
|
{error.message || "Bilinmeyen hata"}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user