Commits

Robert Brewer committed e3dadc8

Removed redundant lines in _cputil.

Comments (0)

Files changed (2)

 _missing = object()
 
 class HTTPError(Error):
-    """ Exception raised when the client has made an error in its request.
+    """ Exception used to return an HTTP error code to the client.
         This exception will automatically set the response status and body.
         
-        A custom body can be pased to the init method in place of the standard error page.
+        A custom body can be pased to the init method in place of the
+        standard error page.
     """
     
     def __init__(self, status=500, body=_missing):
         cherrypy.response.status = self.statusString
 
         if body is _missing:
-            # because the init method is called before the exception is raised
-            # it is impossible to embed the traceback in the error page at this point.
-            # We use a generator so that the error page is generated at a later point (
-            # after the exception is raised).
-            cherrypy.response.body = self.pageGenerator()
-        else:
-            cherrypy.response.body = body
+            # because the init method is called before the exception
+            # is raised it is impossible to embed the traceback in the
+            # error page at this point. We use a generator so that the
+            # error page is generated at a later point (after the
+            # exception is raised).
+            body = self.pageGenerator()
+        
+        cherrypy.response.body = body
     
     def __str__(self):
         return self.statusString
         return ""
     return "".join(traceback.format_exception(*exc))
 
-def getErrorStatusAndPage(status, traceback = None):
-    statusString, message = _HTTPResponses[status]
-    statusString = '%d %s' % (status, statusString)
-    
-    if traceback is None:
-        traceback = ''
-        # get the traceback from formatExc
-        developmentMode = (cherrypy.config.get('server.environment') == 'development')
-        if cherrypy.config.get('server.showTracebacks') or developmentMode:
-            traceback = formatExc()
-    
-    page = _HTTPErrorTemplate(statusString, message, traceback, cherrypy.__version__)
-    
-    return statusString, page
-
-    """formatExc(exc=None) -> exc (or sys.exc_info), formatted."""
-    if exc is None:
-        exc = sys.exc_info()
-    
-    if exc == (None, None, None):
-        return ""
-
-    return "".join(traceback.format_exception(*exc))
-
 def _cpOnError():
     """ Default _cpOnError method """