kennethreitz/requests — pull request #476 by maxcountryman (2012-03-09 16:19:00+00:00)
Title: adding a request_status attribute to HTTPError

HTTPError provides a nice way to handle errors via response.raise_for_status,
however even though the HTTP status code is included in the error message
string, this does not necessarily provide a clean API with which to interface
over the request's status_code when an error occurs.

Particularly this is useful when using a module or class that wraps requests
and returns some parsed response but leaves error handling up to whatever
is using it. For instance, if such a class were to call raise_for_status,
while it's possible to see if a string representation of an HTTP code is in the
error message via str(404) in (str), this isn't as clean as being able to
simply use e.status_code and compare directly via 404 == e.status_code.