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 }); } }; }