fix: API 500 错误返回具体原因,便于线上排查

This commit is contained in:
2026-03-01 21:59:23 +08:00
parent 0e9d4ae43e
commit fe9a52e2e4
+2 -1
View File
@@ -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 });
}
};
}