set_error_page()

set_error_page(filename)

The set_error_page() method of the PSPInstance object calls a given page passing it the 3-tuple returned by sys.exc_info().

This page will produce an error and call the error.psp page:

<%
# psp is an instance of the PSPInstance object
# It exists in all PSP pages
psp.set_error_page('error.psp')
x = 1/0
%>

The error.psp page will have the sys.exc_info() returned tuple available in the exception variable and could send an email to the webmaster:

<%
import traceback as tb

# The tuple returned by sys.exc_info()
# is passed to the error page in a variable named exception
exctype, value, traceback = exception

# format_exception() is used to format the error listing
message = '\n'.join(tb.format_exception(exctype, value, traceback))

#
# Here there would be the code to send an email
# containing the above message to the webmaster
#

%>
<html><body>
<p>This page execution had an error.</p>
<p>An email describing this situation has been sent to the webmaster.</p>
<p style="color:red">
Never show errors to the user. It is here for didatic purposes only.</p>
<pre><%= message %></pre>
</body></html>