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

Changeset 617

Show
Ignore:
Timestamp:
09/08/05 19:02:26
Author:
fumanchu
Message:

Initial fix for #286.

Files:

Legend:

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

    r606 r617  
    3535import time 
    3636import os 
    37 import os.path 
     37#import os.path 
     38 
    3839import cherrypy 
     40from cherrypy.lib import httperrors 
    3941 
    4042 
     
    151153        f.close() 
    152154 
    153 from cherrypy.lib import httperrors 
    154  
    155155def _cpOnHTTPError(): 
    156156    """ Default _cpOnHTTPError method """ 
    157157    status, customMessage = sys.exc_info()[1].getArgs() 
    158158    
    159     # get the error mage 
     159    # get the error page 
    160160    page = httperrors.getErrorPage(status, customMessage = customMessage) 
    161161    cherrypy.response.status, cherrypy.response.body = page 
     
    176176    showTracebacks  = cherrypy.config.get('server.showTracebacks') 
    177177     
     178    logTracebacks  = cherrypy.config.get('server.logTracebacks') 
     179    if logTracebacks: 
     180        cherrypy.log(formatExc()) 
     181     
    178182    response = cherrypy.response 
    179183     
    180184    if not developmentMode and httpErrors: 
    181185        # if it isn't development mode and http errors are turned on 
    182         # set the respose status and render the body 
     186        # set the response status and render the body 
    183187        if response.status == 404: 
    184188            response.status, response.body = httperrors.getErrorPage(404) 
  • trunk/cherrypy/test/test_core.py

    r605 r617  
    272272        'server.logFile': logFile, 
    273273    }, 
     274    '/error': { 
     275        'server.logFile': logFile, 
     276        'server.logTracebacks': True, 
     277    }, 
    274278}) 
    275279 
     
    392396        data = open(logFile, "rb").readlines() 
    393397        self.assertEqual(data[0][-53:], ' HTTP INFO 127.0.0.1 - GET /params/?thing=a HTTP/1.1\n') 
     398         
     399        # Test that tracebacks get written to the error log. 
     400        ignore = helper.webtest.ignored_exceptions 
     401        ignore.append(ValueError) 
     402        try: 
     403            self.getPage("/error/page_method") 
     404            self.assertInBody("raise ValueError()") 
     405            data = open(logFile, "rb").readlines() 
     406            self.assertEqual(data[2][-41:], ' INFO Traceback (most recent call last):\n') 
     407            self.assertEqual(data[8], '    raise ValueError()\n') 
     408        finally: 
     409            ignore.pop() 
    394410     
    395411    def testRedirect(self): 

Hosted by WebFaction

Log in as guest/cpguest to create tickets