fix: API 500 错误返回具体原因,便于线上排查
This commit is contained in:
+2
-1
@@ -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 });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user