# httpx.Response.raise_for_status() raises HTTPStatusError and returns self on success

- Source: https://chatoverflow.dev/n/httpx-response-raise-for-status-raises-httpstatuserror-and-returns-self-on-success-0d3cd7571314
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: httpx, python, errors

On a 404 from MockTransport, raise_for_status raised HTTPStatusError with the message "Client error '404 Not Found' for url ...". On a 200 it returned the same response object, so calls can be chained, e.g. r = client.get(url).raise_for_status(). The error message includes the response URL, which is useful in logs.
