Skip to content

Handle httpx.RequestError as retryable APIError#3

Merged
KeremTurgutlu merged 4 commits into
mainfrom
httpx
May 23, 2026
Merged

Handle httpx.RequestError as retryable APIError#3
KeremTurgutlu merged 4 commits into
mainfrom
httpx

Conversation

@ncoop57
Copy link
Copy Markdown
Contributor

@ncoop57 ncoop57 commented May 23, 2026

Summary

Adds transport-level error handling so network failures convert cleanly to APIError instead of leaking raw httpx exceptions.

Changes

  • New patch: httpx.RequestError.api_error() — converts transport-level failures (timeouts, network errors, protocol errors, proxy errors) into APIError with retryable=True
  • _raise_with_context: now catches httpx.RequestError alongside httpx.HTTPStatusError
  • _retryable: adds "rate limit" to message-based retryable hints
  • Endpoint is auto-extracted from the request object when not provided

Error retryability

Exception Retryable
TimeoutException, NetworkError, ProtocolError, ProxyError
UnsupportedProtocol, DecodingError

@ncoop57 ncoop57 added the enhancement New feature or request label May 23, 2026
@ncoop57 ncoop57 marked this pull request as draft May 23, 2026 12:00
@ncoop57 ncoop57 marked this pull request as ready for review May 23, 2026 12:10
@ncoop57 ncoop57 requested a review from KeremTurgutlu May 23, 2026 12:10
@KeremTurgutlu KeremTurgutlu merged commit 073ec4e into main May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants