From 5d895ae12c024bccedc49948bb24f6b09f60dc18 Mon Sep 17 00:00:00 2001 From: TradeMate Dev Date: Thu, 11 Jun 2026 19:38:05 +0800 Subject: [PATCH] fix: standardize error response format - Fix exchange.py: replace {'error':...} with HTTPException(detail=...) - Fix payment/admin/teams/quotation: str(e) messages are already user-safe - Confirm admin_search.py test endpoint uses correct probe pattern - Confirm frontend has no raw alert() calls (already uses ElMessage) --- backend/app/api/v1/exchange.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app/api/v1/exchange.py b/backend/app/api/v1/exchange.py index 2393e91..ae8fba7 100644 --- a/backend/app/api/v1/exchange.py +++ b/backend/app/api/v1/exchange.py @@ -1,4 +1,4 @@ -from fastapi import APIRouter +from fastapi import APIRouter, HTTPException from app.services.exchange import ExchangeRateService from datetime import datetime @@ -14,7 +14,7 @@ async def convert_currency( ): rate = await service.get_rate(from_currency, to_currency) if rate is None: - return {"error": f"No rate available for {from_currency} -> {to_currency}"} + raise HTTPException(status_code=404, detail=f"汇率不可用: {from_currency} → {to_currency}") return { "from_currency": from_currency.upper(),