HTTPError

This commit is contained in:
Kenneth Reitz
2011-10-23 18:27:54 -04:00
parent a9822b0bb6
commit a548b6249d
3 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -29,5 +29,5 @@ from .sessions import session
from .status_codes import codes
from .exceptions import (
RequestException, AuthenticationError, Timeout, URLRequired,
TooManyRedirects
TooManyRedirects, HTTPError
)
+3
View File
@@ -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."""
+3 -6
View File
@@ -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)