venice_ai.utils.errors
Shared error-wrapping utilities for aiohttp requests.
Provides :func:wrap_aiohttp_errors, an async context manager that
translates low-level aiohttp / asyncio exceptions into the SDK's
:class:~venice_ai.exceptions.APITimeoutError and
:class:~venice_ai.exceptions.APIConnectionError.
This is the single, canonical aiohttp/asyncio error-translation context manager, used by both the client request path and the multipart resource path.
wrap_aiohttp_errors
@asynccontextmanager
async def wrap_aiohttp_errors() -> AsyncIterator[None]
Translate aiohttp / asyncio errors into SDK exceptions.
Usage:
from venice_ai.utils.errors import wrap_aiohttp_errors
async with wrap_aiohttp_errors():
response = await session.request(**kwargs)
The exception ordering is intentional — more specific types are caught
before their base classes:
1. ``aiohttp.ServerTimeoutError`` → :class:`APITimeoutError`
2. ``TimeoutError`` (includes ``asyncio.TimeoutError``) → :class:`APITimeoutError`
3. ``aiohttp.ClientConnectorError`` → :class:`APIConnectionError`
4. ``aiohttp.ClientError`` (catch-all) → :class:`APIConnectionError`