Robert Brewer avatar Robert Brewer committed bb06c24

Fix for #307. Made InternalError a subclass of HTTPError(500). Removed all use of InternalError from the framework; it should be removed in 2.2.

Comments (0)

Files changed (2)

cherrypy/_cperror.py

 class Error(Exception):
     pass
 
-class InternalError(Error):
-    """ Error that should never happen """
-    pass
-
 class NotReady(Error):
     """A request was made before the app server has been started."""
     pass
     def __init__(self, path):
         self.args = (path,)
         HTTPError.__init__(self, 404, "The path %s was not found." % repr(path))
+
+
+class InternalError(HTTPError):
+    """ Error that should never happen """
+    
+    def __init__(self, message=None):
+        HTTPError.__init__(self, 500, message)

cherrypy/_cputil.py

     
     try:
         return globals()[name]
-    except KeyError:
-        raise cherrypy.InternalError("Special attribute %s could not be found"
-                                     % repr(name))
+    except KeyError:
+        msg = "Special attribute %s could not be found" % repr(name)
+        raise cherrypy.HTTPError(500, msg)
 
 def getSpecialAttributePath(name):
     """ Return the path to the special attribute """
         for i in xrange(len(objectList) - 1, -1, -1):
             if hasattr(objectList[i], name):
                 return "/" + "/".join(pathList[:i] + [name])
-    raise cherrypy.InternalError("Special attribute %s could not be found"
-                                 % repr(name))
+    msg = "Special attribute %s could not be found" % repr(name)
+    raise cherrypy.HTTPError(500, msg)
 
 
 def logtime():
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.