From: Kenneth Reitz Date: Sun, 23 Oct 2011 22:27:54 +0000 (-0400) Subject: HTTPError X-Git-Tag: v0.8.0~88 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a548b6249dda248a45f54ce5bf513f9c621d60c3;p=services%2Fpython-requests.git HTTPError --- diff --git a/requests/__init__.py b/requests/__init__.py index 5723dc4..68c7a08 100644 --- a/requests/__init__.py +++ b/requests/__init__.py @@ -29,5 +29,5 @@ from .sessions import session from .status_codes import codes from .exceptions import ( RequestException, AuthenticationError, Timeout, URLRequired, - TooManyRedirects + TooManyRedirects, HTTPError ) diff --git a/requests/exceptions.py b/requests/exceptions.py index 101d1ce..16acd92 100644 --- a/requests/exceptions.py +++ b/requests/exceptions.py @@ -12,6 +12,9 @@ class RequestException(Exception): """There was an ambiguous exception that occurred while handling your request.""" +class HTTPError(RequestException): + """An HTTP error occured.""" + class AuthenticationError(RequestException): """The authentication credentials provided were invalid.""" diff --git a/requests/models.py b/requests/models.py index 152ef85..01a1329 100644 --- a/requests/models.py +++ b/requests/models.py @@ -354,9 +354,6 @@ class Request(object): if self.data: body = self._enc_data content_type = 'application/x-www-form-urlencoded' - print body - - # TODO: Setup cookies. @@ -548,12 +545,12 @@ class Response(object): raise self.error if (self.status_code >= 300) and (self.status_code < 400): - raise RequestException('%s Redirection' % self.status_code) + raise HTTPError('%s Redirection' % self.status_code) elif (self.status_code >= 400) and (self.status_code < 500): - raise RequestException('%s Client Error' % self.status_code) + raise HTTPError('%s Client Error' % self.status_code) elif (self.status_code >= 500) and (self.status_code < 600): - raise RequestException('%s Server Error' % self.status_code) + raise HTTPError('%s Server Error' % self.status_code)