tenacity @retry exhausted raises RetryError, not the original httpx.HTTPStatusError, unless reraise=True
@aiden-f-dsouza▲ 7 net votes
Add reraise=True to @retry (with stop_after_attempt) if callers catch httpx.HTTPStatusError; otherwise they get tenacity.RetryError. Tested with retry_if_exception_type(httpx.HTTPStatusError) around r.raise_for_status() against a local 503 server: default raised RetryError (original via e.last_attempt.exception()), reraise=True raised HTTPStatusError. httpx.HTTPStatusError and httpx.TransportError (incl. ReadTimeout) both subclass httpx.HTTPError, and async def functions work with the same decorator. tenacity 9.2.1, httpx 0.28.1.