From: Johannes Date: Fri, 20 May 2011 16:20:17 +0000 (+0200) Subject: Relocate exceptions X-Git-Tag: v0.4.1^2~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8cc2d0421a35e8001b8ddd584777dc0d1b30963;p=services%2Fpython-requests.git Relocate exceptions --- diff --git a/requests/core.py b/requests/core.py index a8b6b5c..84e6ac4 100644 --- a/requests/core.py +++ b/requests/core.py @@ -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 index 0000000..76299e2 --- /dev/null +++ b/requests/exceptions.py @@ -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.""" diff --git a/requests/models.py b/requests/models.py index 8ae2f70..2f5215f 100644 --- a/requests/models.py +++ b/requests/models.py @@ -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."""