Relocate exceptions

This commit is contained in:
Johannes
2011-05-20 18:20:17 +02:00
parent a00dc1abf3
commit c8cc2d0421
3 changed files with 25 additions and 22 deletions
+1
View File
@@ -22,3 +22,4 @@ __copyright__ = 'Copyright 2011 Kenneth Reitz'
from models import HTTPError, auth_manager
from api import *
from exceptions import *
+23
View File
@@ -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."""
+1 -22
View 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."""