Home

  Documentation

  Download

  News

  Examples

error.py Source Code

C:/Work/Lemon/Backups/Lemon-0.2.10/Lemon-0.2.10/../../doc/examples/code/error.py
"""Simple example of how to create your own custom error pages using the tb module.

You could, of course, do much cleverer things such as writing the errors to a log, emailing them to the sysadmin
or many other things.
"""

import sys, re
sys.path.append('../')
sys.path.append('../../../')

def exceptionHandler(dict):
    print "Content-type: text/html

"
    print """
<html>
<body>
<h1>%s</h1>
<p>%s</p>
</body>
</html>"""%(dict['type'], dict['value'])
import lemon
import lemon.tb; lemon.tb.enableCustom(exceptionHandler)

raise Exception('It caught the Exception and properly displayed the html page!')

© 2002-2003 James Gardner