refactor(api): unify typed error contract across draft pricing and publish flows
standardize typed error responses across draft, pricing and publish endpoints reduce contract drift between related flows keep client-side handling more predictable and consistent
This commit is contained in:
@@ -30,6 +30,7 @@ from app.schemas.pricing import (
|
||||
PricingCategoryUpdateResponse,
|
||||
)
|
||||
from app.security.auth import require_api_key
|
||||
from app.services.api_errors import raise_unprocessable
|
||||
from app.services.draft_guard import validate_expected_draft_version_if_provided
|
||||
|
||||
router = APIRouter()
|
||||
@@ -213,9 +214,10 @@ async def create_price_rule_endpoint(
|
||||
try:
|
||||
amount = Decimal(payload.amount)
|
||||
except Exception:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail="Некорректная сумма",
|
||||
raise_unprocessable(
|
||||
code="invalid_amount",
|
||||
message="Некорректная сумма",
|
||||
amount=payload.amount,
|
||||
)
|
||||
|
||||
price_rule_id = await create_price_rule(
|
||||
@@ -273,9 +275,10 @@ async def update_price_rule_endpoint(
|
||||
try:
|
||||
amount = Decimal(payload.amount)
|
||||
except Exception:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail="Некорректная сумма",
|
||||
raise_unprocessable(
|
||||
code="invalid_amount",
|
||||
message="Некорректная сумма",
|
||||
amount=payload.amount,
|
||||
)
|
||||
|
||||
row = await update_price_rule(
|
||||
|
||||
Reference in New Issue
Block a user