Handle 402 Payment Required from Evotor API gracefully

Return empty list for groups/products when Evotor returns 402,
instead of crashing the refresh with an unhandled HTTP error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
mguschin
2026-03-09 18:04:13 +03:00
parent 40e7abd012
commit 9558333c94

View File

@@ -33,6 +33,8 @@ async def fetch_groups(access_token: str, store_id: str) -> list[dict]:
headers={"Authorization": f"Bearer {access_token}"},
timeout=15,
)
if resp.status_code == 402:
return []
resp.raise_for_status()
data = resp.json()
items = data.get("items", data) if isinstance(data, dict) else data
@@ -46,6 +48,8 @@ async def fetch_products(access_token: str, store_id: str) -> list[dict]:
headers={"Authorization": f"Bearer {access_token}"},
timeout=15,
)
if resp.status_code == 402:
return []
resp.raise_for_status()
data = resp.json()
items = data.get("items", data) if isinstance(data, dict) else data