Skip to content

Commit 08ced9c

Browse files
lesnik512claude
andcommitted
fix(errors): correct NetworkError docstring — close, not pool
PoolTimeout inherits from httpx2.TimeoutException, not NetworkError, so the bucket is connect/read/write/close. The dispatch logic is unchanged (PoolTimeout was already caught by the timeout branch above NetworkError), but the docstring was misleading future maintainers and the upcoming Retry middleware author about what NetworkError actually wraps. Update spec + plan to match. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 478fa37 commit 08ced9c

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎planning/plans/2026-06-05-retry-and-retry-budget-plan.md‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ Expected: FAIL (`ImportError: cannot import name 'NetworkError'`).
139139
Edit `src/httpware/errors.py`. Add a new class immediately after the existing `class TransportError`:
140140
```python
141141
class NetworkError(TransportError):
142-
"""Transient network-layer failure (connect/read/write/pool). Safe to retry."""
142+
"""Transient network-layer failure (connect/read/write/close). Safe to retry.
143+
144+
Pool-acquisition timeouts are NOT under this class; they raise ``TimeoutError``
145+
via ``httpx2.PoolTimeout`` (a ``TimeoutException`` subclass).
146+
"""
143147
```
144148

145149
Run: `uv run pytest tests/test_errors.py::test_network_error_is_transport_error -v`
@@ -220,7 +224,7 @@ Becomes:
220224

221225
The `httpx2.NetworkError` branch must come BEFORE `httpx2.HTTPError` (HTTPError is the broader base). `httpx2.NetworkError` is httpx's documented base for `ConnectError`, `ReadError`, `WriteError`, `PoolTimeout` — if `httpx2`'s symbol name differs (e.g., `httpx2.exceptions.NetworkError`), use whichever import path mirrors the existing `httpx2.ConnectError` import in `tests/test_error_mapping_terminal.py` (which works via top-level `httpx2`).
222226

223-
If `httpx2.NetworkError` does not exist, fall back to enumerating the transient subset explicitly: `except (httpx2.ConnectError, httpx2.ReadError, httpx2.WriteError, httpx2.PoolTimeout) as exc:`. The plan author has confirmed `httpx2.ConnectError` and `httpx2.ReadTimeout` already work in the existing tests; the enumeration fallback is safe.
227+
If `httpx2.NetworkError` does not exist, fall back to enumerating the transient subset explicitly: `except (httpx2.ConnectError, httpx2.ReadError, httpx2.WriteError, httpx2.CloseError) as exc:`. (`PoolTimeout` is NOT in this list — it inherits from `httpx2.TimeoutException` and is already caught by the timeout branch above.) The plan author has confirmed `httpx2.ConnectError` and `httpx2.ReadTimeout` already work in the existing tests; the enumeration fallback is safe.
224228

225229
- [ ] **Step 6: Run the new terminal-mapping test**
226230

@@ -267,7 +271,7 @@ git add src/httpware/errors.py src/httpware/client.py tests/test_errors.py tests
267271
git commit -m "feat(errors): add NetworkError(TransportError) for transient httpx2 failures
268272
269273
Refines _terminal so httpx2.NetworkError-family exceptions (ConnectError, ReadError,
270-
WriteError, PoolTimeout) map to httpware.NetworkError. InvalidURL and CookieConflict
274+
WriteError, CloseError) map to httpware.NetworkError. InvalidURL and CookieConflict
271275
stay bare TransportError. Prerequisite for the Retry middleware so it can retry
272276
transient failures without retrying typos."
273277
```

‎planning/specs/2026-06-05-retry-and-retry-budget-design.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The current `AsyncClient._terminal` maps every non-timeout `httpx2.HTTPError` (i
2828
```python
2929
# In src/httpware/errors.py:
3030
class NetworkError(TransportError):
31-
"""Transient network-layer failure (connect / read / write / pool). Safe to retry."""
31+
"""Transient network-layer failure (connect / read / write / close). Safe to retry."""
3232
```
3333

3434
And refines the terminal mapping so that `httpx2`'s transient-network exception family (`httpx2.NetworkError` per httpx convention, or whichever symbols httpx2 exposes for the same hierarchy) raises `httpware.NetworkError` rather than the broader `TransportError`. `InvalidURL` and `CookieConflict` continue to raise `TransportError` directly so they are NOT retried. Existing tests catching `TransportError` keep working (`NetworkError` is a subclass).

‎src/httpware/errors.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ class TransportError(ClientError):
4141

4242

4343
class NetworkError(TransportError):
44-
"""Transient network-layer failure (connect/read/write/pool). Safe to retry."""
44+
"""Transient network-layer failure (connect/read/write/close). Safe to retry.
45+
46+
Pool-acquisition timeouts are NOT under this class; they raise ``TimeoutError``
47+
via ``httpx2.PoolTimeout`` (a ``TimeoutException`` subclass).
48+
"""
4549

4650

4751
class TimeoutError(ClientError, builtins.TimeoutError): # noqa: A001

0 commit comments

Comments
 (0)