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(),