Alternatively you can create an ErrorInformation object to display the error information:
try:
    raise Exception('This error will be caught and nicely displayed')
except:
    import web.error
    errorInfo = web.error.error()
    print error.textException()
This would aproduce the same output described in the previous example.
The web.error.error() function returns an ErrorInformation object which can be used to format exception tuples in a variety of useful ways. Below is the API reference for the web.error.error() function and the Information objects returned.
| [error=sys.exc_info()], [context=5]) | 
Return an ErrorInformation object representing the error.
5.
Error Information objects have the following attributes:
sys.exc_info() if no error was specified.
'text' or 'html'.
Information object was created. Note:
 This may not be the time the error occured.
Error Information objects have the following methods for displaying error information Note:
 Python 2.1 and below do not have the cgitb module and so have slightly different implementations of the html() and text() methods so the output of those methods may be different to the output generated using Python 2.2 and above. 
| output, [format], [error], [context]) | 
'traceback' for a traceback, 'code' for a code listing or 'debug' for code and traceback listing suitable for script debugging. The method returns the result of calling the respective method below.
| [format], [error]) | 
'text' or 'html'. If not specified format takes the value of format. error should be an error tuple as returned by sys.exc_info(). If not specified error is used.
| [format], [error], [context]) | 
'text' or 'html'. If not specified format takes the value of format. context is the number of lines of code to display at each stage in the traceback information. If not specified context is used. error should be an error tuple as returned by sys.exc_info(). If not specified error is used.
| [format], [error], [context]) | 
'text' or 'html'. If not specified format takes the value of format.  context is the number of lines of code to display at each stage in the traceback information. If not specified context is used. error should be an error tuple as returned by sys.exc_info(). If not specified error is used.