From fe9a52e2e453f7b7b9ca21eac1edc19a8c60d628 Mon Sep 17 00:00:00 2001 From: kurihada Date: Sun, 1 Mar 2026 21:59:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20API=20500=20=E9=94=99=E8=AF=AF=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=85=B7=E4=BD=93=E5=8E=9F=E5=9B=A0=EF=BC=8C=E4=BE=BF?= =?UTF-8?q?=E4=BA=8E=E7=BA=BF=E4=B8=8A=E6=8E=92=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/api.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/api.ts b/src/lib/api.ts index f3879dc..3a91cda 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -56,8 +56,9 @@ export function apiHandler(handler: RouteHandler): RouteHandler { { status: 409 }, ); } + const detail = e instanceof Error ? `${e.name}: ${e.message}` : String(e); console.error(`[API ${req.method} ${req.nextUrl.pathname}]`, e); - return NextResponse.json({ error: "操作失败" }, { status: 500 }); + return NextResponse.json({ error: `操作失败 [${detail}]` }, { status: 500 }); } }; }