HTTPError
authorKenneth Reitz <me@kennethreitz.com>
Sun, 23 Oct 2011 22:27:54 +0000 (18:27 -0400)
committerKenneth Reitz <me@kennethreitz.com>
Sun, 23 Oct 2011 22:27:54 +0000 (18:27 -0400)
requests/__init__.py
requests/exceptions.py
requests/models.py

index 5723dc441350ebbc35b62137423883c8cb6c5cc0..68c7a08909c98d05beb7df7e76b8be5662848f90 100644 (file)
@@ -29,5 +29,5 @@ from .sessions import session
 from .status_codes import codes
 from .exceptions import (
     RequestException, AuthenticationError, Timeout, URLRequired,
-    TooManyRedirects
+    TooManyRedirects, HTTPError
 )
index 101d1ce6007eb1e6d2e357f76be1fa91231508a2..16acd9252cd0b594abeb43733763f52e90f48122 100644 (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."""
 
index 152ef854b3206aa2dba49893a9378a4d76f04b34..01a1329d0e319ea38406668cada87b8537fd1f8b 100644 (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)