1.6.6 Example

Take a look at the example below demonstrating a handler which emails information to a developer:

#!/usr/bin/env python

# show python where the web modules are
import sys; sys.path.append('../'); sys.path.append('../../../')

import web.error; web.error.handle()
raise Exception('This is a test exception')

Warning: If you run this example please make sure you replace the email addresses with your own email address in. You may need to change the path of sendmail or use an SMTP server instead. See the web.mail module documentation for help with this.

Note: If an exception occurs in your custom error handling function it may be difficult to track down. You can put your code inside a try except block and make sure some sensible output is returned in the event of an Exception being raised.