Changeset 644
- Timestamp:
- 09/14/05 02:20:41
- Files:
-
- trunk/cherrypy/_cperror.py (modified) (2 diffs)
- trunk/cherrypy/_cputil.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cperror.py
r639 r644 174 174 175 175 class HTTPError(Error): 176 """ Exception raised when the client has made an error in its request.176 """ Exception used to return an HTTP error code to the client. 177 177 This exception will automatically set the response status and body. 178 178 179 A custom body can be pased to the init method in place of the standard error page. 179 A custom body can be pased to the init method in place of the 180 standard error page. 180 181 """ 181 182 … … 191 192 192 193 if body is _missing: 193 # because the init method is called before the exception is raised 194 # it is impossible to embed the traceback in the error page at this point. 195 # We use a generator so that the error page is generated at a later point ( 196 # after the exception is raised). 197 cherrypy.response.body = self.pageGenerator() 198 else: 199 cherrypy.response.body = body 194 # because the init method is called before the exception 195 # is raised it is impossible to embed the traceback in the 196 # error page at this point. We use a generator so that the 197 # error page is generated at a later point (after the 198 # exception is raised). 199 body = self.pageGenerator() 200 201 cherrypy.response.body = body 200 202 201 203 def __str__(self): trunk/cherrypy/_cputil.py
r642 r644 210 210 return "".join(traceback.format_exception(*exc)) 211 211 212 def getErrorStatusAndPage(status, traceback = None):213 statusString, message = _HTTPResponses[status]214 statusString = '%d %s' % (status, statusString)215 216 if traceback is None:217 traceback = ''218 # get the traceback from formatExc219 developmentMode = (cherrypy.config.get('server.environment') == 'development')220 if cherrypy.config.get('server.showTracebacks') or developmentMode:221 traceback = formatExc()222 223 page = _HTTPErrorTemplate(statusString, message, traceback, cherrypy.__version__)224 225 return statusString, page226 227 """formatExc(exc=None) -> exc (or sys.exc_info), formatted."""228 if exc is None:229 exc = sys.exc_info()230 231 if exc == (None, None, None):232 return ""233 234 return "".join(traceback.format_exception(*exc))235 236 212 def _cpOnError(): 237 213 """ Default _cpOnError method """

