httpx icon indicating copy to clipboard operation
httpx copied to clipboard

Improve error message formatting in Response class to not give a link for unofficial codes.

Open gitpushoriginmaster opened this issue 5 months ago • 0 comments

Summary

When seeing an unofficial status code the suggested further reading link to MDN Web Docs will be broken since it contains only official codes.

As an example, the unofficial code for 529 will direct the developer to https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/529, a web page that does not exist.

The change adds the line with the link only if the status code has a reason phrase, meaning it is a part of the 'codes' Enum.

Checklist

  • [x] I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • [ ] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
    • There are no message tests for raise_for_status.
  • [ ] I've updated the documentation accordingly.
    • No behavioral change, so no documentation to update.

gitpushoriginmaster avatar Jul 21 '25 11:07 gitpushoriginmaster