Robert Brewer avatar Robert Brewer committed 333debc

Reversed httperrors references in bareError (which must not be allowed to fail).

Comments (0)

Files changed (1)

cherrypy/_cphttptools.py

     as-is to the body.
     """
     
-    try:
-        # try to return a nice error page if we are in production mode and http errors
-        # are enabled
-        isProduction = cherrypy.config.get('server.environment') == 'production'
-        httpErrors = cherrypy.config.get('server.httpErrors')
-        
-        if isProduction and httpErrors:
-            if not extrabody:
-                extrabody = ''
-            status, _body = cherrypy.lib.httperrors.getErrorPage(500, extrabody)
-            headers = [('Content-Length', str(len(_body))), ('Content-Type', 'text/html')]
-            return (status, headers, _body)
-        else:
-            # raise a dummy exception to force a plain error message
-            raise Exception()
-    except:
-        # if there was a problem generating the error page
-        # then return a basic message
-        body = "Unrecoverable error in the server."
-        if extrabody is not None:
-            body += "\n" + extrabody
-        
-        return ("500 Internal Server Error",
-            [('Content-Type', 'text/plain'),
-             ('Content-Length', str(len(body)))],
-            [body])
+    # The whole point of this function is to be a last line-of-defense
+    # in handling errors. That is, it must not raise any errors itself;
+    # it cannot be allowed to fail. Therefore, don't add to it!
+    # In particular, don't call any other CP functions.
+    body = "Unrecoverable error in the server."
+    if extrabody is not None:
+        body += "\n" + extrabody
+    
+    return ("500 Internal Server Error",
+        [('Content-Type', 'text/plain'),
+         ('Content-Length', str(len(body)))],
+        [body])
 
 
 
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.