Relocate exceptions
authorJohannes <jgorset@gmail.com>
Fri, 20 May 2011 16:20:17 +0000 (18:20 +0200)
committerJohannes <jgorset@gmail.com>
Fri, 20 May 2011 16:20:17 +0000 (18:20 +0200)
requests/core.py
requests/exceptions.py [new file with mode: 0644]
requests/models.py

index a8b6b5c..84e6ac4 100644 (file)
@@ -22,3 +22,4 @@ __copyright__ = 'Copyright 2011 Kenneth Reitz'
 
 from models import HTTPError, auth_manager
 from api import *
+from exceptions import *
diff --git a/requests/exceptions.py b/requests/exceptions.py
new file mode 100644 (file)
index 0000000..76299e2
--- /dev/null
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+
+"""
+requests.models
+~~~~~~~~~~~~~~~
+
+"""
+
+class RequestException(Exception):
+    """There was an ambiguous exception that occured while handling your
+    request."""
+
+class AuthenticationError(RequestException):
+    """The authentication credentials provided were invalid."""
+    
+class Timeout(RequestException):
+    """The request timed out."""
+
+class URLRequired(RequestException):
+    """A valid URL is required to make a request."""
+
+class InvalidMethod(RequestException):
+    """An inappropriate method was attempted."""
index 8ae2f70..2f5215f 100644 (file)
@@ -19,6 +19,7 @@ from .monkeys import Request as _Request, HTTPBasicAuthHandler, HTTPDigestAuthHa
 from .structures import CaseInsensitiveDict
 from .packages.poster.encode import multipart_encode
 from .packages.poster.streaminghttp import register_openers, get_handlers
+from .exceptions import RequestException, AuthenticationError, Timeout, URLRequired, InvalidMethod
 
 
 
@@ -480,25 +481,3 @@ class AuthObject(object):
             self.handler = self._handlers.get(handler.lower(), urllib2.HTTPBasicAuthHandler)
         else:
             self.handler = handler
-
-
-# ----------
-# Exceptions
-# ----------
-
-
-class RequestException(Exception):
-    """There was an ambiguous exception that occured while handling your
-    request."""
-
-class AuthenticationError(RequestException):
-    """The authentication credentials provided were invalid."""
-    
-class Timeout(RequestException):
-    """The request timed out."""
-
-class URLRequired(RequestException):
-    """A valid URL is required to make a request."""
-
-class InvalidMethod(RequestException):
-    """An inappropriate method was attempted."""