Commits

Anonymous committed be300d8

Make a CherryPyException, from which all exceptions inherit, and also is available from "import cherrypy".

Comments (0)

Files changed (2)

cherrypy/__init__.py

 import os as _os
 _localdir = _os.path.dirname(__file__)
 
-from cherrypy._cperror import HTTPError, HTTPRedirect, InternalRedirect, NotFound
+from cherrypy._cperror import HTTPError, HTTPRedirect, InternalRedirect, NotFound, CherryPyException
 from cherrypy._cperror import TimeoutError
 
 from cherrypy import _cptools

cherrypy/_cperror.py

 from cherrypy.lib import http as _http
 
 import exceptions
-class Exception(exceptions.Exception):
+class CherryPyException(exceptions.Exception):
     pass
 
-class InternalRedirect(Exception):
+class InternalRedirect(CherryPyException):
     """Exception raised when processing should be handled by a different path.
     
     If you supply a query string, it will replace request.params.
         # error can have access to it.
         self.path = path
         
-        Exception.__init__(self, path)
+        CherryPyException.__init__(self, path)
 
 
 
-class HTTPRedirect(Exception):
+class HTTPRedirect(CherryPyException):
     """Exception raised when the request should be redirected.
     
     The new URL must be passed as the first argument to the Exception,
                 raise ValueError("status must be between 300 and 399.")
         
         self.status = status
-        Exception.__init__(self, abs_urls, status)
+        CherryPyException.__init__(self, abs_urls, status)
     
     def set_response(self):
         """Modify cherrypy.response status, headers, and body to represent self.
         raise self
 
 
-class HTTPError(Exception):
+class HTTPError(CherryPyException):
     """ Exception used to return an HTTP error code (4xx-5xx) to the client.
         This exception will automatically set the response status and body.
         
         if status < 400 or status > 599:
             raise ValueError("status must be between 400 and 599.")
         self.message = message
-        Exception.__init__(self, status, message)
+        CherryPyException.__init__(self, status, message)
     
     def set_response(self):
         """Modify cherrypy.response status, headers, and body to represent self.
         HTTPError.__init__(self, 404, "The path %r was not found." % path)
 
 
-class TimeoutError(Exception):
+class TimeoutError(CherryPyException):
     """Exception raised when Response.timed_out is detected."""
     pass