Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 623

Show
Ignore:
Timestamp:
09/11/05 00:03:10
Author:
fumanchu
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cphttptools.py

    r619 r623  
    452452    """ 
    453453     
    454     try: 
    455         # try to return a nice error page if we are in production mode and http errors 
    456         # are enabled 
    457         isProduction = cherrypy.config.get('server.environment') == 'production' 
    458         httpErrors = cherrypy.config.get('server.httpErrors') 
    459          
    460         if isProduction and httpErrors: 
    461             if not extrabody: 
    462                 extrabody = '' 
    463             status, _body = cherrypy.lib.httperrors.getErrorPage(500, extrabody) 
    464             headers = [('Content-Length', str(len(_body))), ('Content-Type', 'text/html')] 
    465             return (status, headers, _body) 
    466         else: 
    467             # raise a dummy exception to force a plain error message 
    468             raise Exception() 
    469     except: 
    470         # if there was a problem generating the error page 
    471         # then return a basic message 
    472         body = "Unrecoverable error in the server." 
    473         if extrabody is not None: 
    474             body += "\n" + extrabody 
    475          
    476         return ("500 Internal Server Error", 
    477             [('Content-Type', 'text/plain'), 
    478              ('Content-Length', str(len(body)))], 
    479             [body]) 
     454    # The whole point of this function is to be a last line-of-defense 
     455    # in handling errors. That is, it must not raise any errors itself; 
     456    # it cannot be allowed to fail. Therefore, don't add to it! 
     457    # In particular, don't call any other CP functions. 
     458    body = "Unrecoverable error in the server." 
     459    if extrabody is not None: 
     460        body += "\n" + extrabody 
     461     
     462    return ("500 Internal Server Error", 
     463        [('Content-Type', 'text/plain'), 
     464         ('Content-Length', str(len(body)))], 
     465        [body]) 
    480466 
    481467 

Hosted by WebFaction

Log in as guest/cpguest to create tickets