Skip to content

Commit

Permalink
Merge of maxcountryman
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Reitz committed Mar 9, 2012
1 parent 9f55f50 commit 0a1e527
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Expand Up @@ -87,3 +87,4 @@ Patches and Suggestions
- Brendan Maguire <maguire.brendan@gmail.com>
- Chris Dary
- Danver Braganza <danverbraganza@gmail.com>
- Max Countryman
1 change: 1 addition & 0 deletions requests/exceptions.py
Expand Up @@ -14,6 +14,7 @@ class RequestException(RuntimeError):

class HTTPError(RequestException):
"""An HTTP error occurred."""
response = None

class ConnectionError(RequestException):
"""A Connection error occurred."""
Expand Down
13 changes: 10 additions & 3 deletions requests/models.py
Expand Up @@ -800,10 +800,17 @@ def raise_for_status(self, allow_redirects=True):
raise self.error

if (self.status_code >= 300) and (self.status_code < 400) and not allow_redirects:
raise HTTPError('%s Redirection' % self.status_code)
http_error = HTTPError('%s Redirection' % self.status_code)
http_error.response = self
raise http_error

elif (self.status_code >= 400) and (self.status_code < 500):
raise HTTPError('%s Client Error' % self.status_code)
http_error = HTTPError('%s Client Error' % self.status_code)
http_error.response = self
raise http_error


elif (self.status_code >= 500) and (self.status_code < 600):
raise HTTPError('%s Server Error' % self.status_code)
http_error = HTTPError('%s Server Error' % self.status_code)
http_error.response = self
raise http_error

0 comments on commit 0a1e527

Please sign in to comment.