From 899171d43429c135a442dd23299747ac3a866a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=87=E8=96=87=E5=AE=89?= Date: Mon, 19 Jan 2026 22:31:27 +0800 Subject: [PATCH] a --- backend/api/routes/account.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/backend/api/routes/account.py b/backend/api/routes/account.py index 6890e24..ad81a68 100644 --- a/backend/api/routes/account.py +++ b/backend/api/routes/account.py @@ -232,8 +232,9 @@ async def ensure_position_sltp(symbol: str): except HTTPException: raise except Exception as e: - logger.error(f"{symbol} 补挂止盈止损失败: {e}", exc_info=True) - raise HTTPException(status_code=500, detail=f"补挂止盈止损失败: {str(e)}") + msg = str(e) or repr(e) or "unknown error" + logger.error(f"{symbol} 补挂止盈止损失败: {msg}", exc_info=True) + raise HTTPException(status_code=500, detail=f"补挂止盈止损失败: {msg}") @router.post("/positions/sltp/ensure-all") @@ -277,8 +278,18 @@ async def ensure_all_positions_sltp(limit: int = Query(50, ge=1, le=200, descrip "open_protection_orders": res.get("open_protection_orders"), } ) + except HTTPException as he: + errors.append( + { + "symbol": sym, + "ok": False, + "status_code": getattr(he, "status_code", None), + "detail": getattr(he, "detail", None), + } + ) except Exception as e: - errors.append({"symbol": sym, "ok": False, "error": str(e)}) + msg = str(e) or repr(e) or "unknown error" + errors.append({"symbol": sym, "ok": False, "error": msg}) return { "total": len(symbols),