Author: chrisz
Date: Sun Jan 25 06:41:36 2009
New Revision: 7764
Modified:
Webware/trunk/WebKit/Examples/Error.py
Log:
Improved the error example servlet. The error is now only raised after you click a button, and you can choose the type of the error (including old style string exception, to ensure these work as well).
Modified: Webware/trunk/WebKit/Examples/Error.py
==============================================================================
--- Webware/trunk/WebKit/Examples/Error.py (original)
+++ Webware/trunk/WebKit/Examples/Error.py Sun Jan 25 06:41:36 2009
@@ -3,6 +3,29 @@
class Error(ExamplePage):
- def writeBody(self):
- self.write('<p>About to raise an exception...</p>')
- import UnknownModule
+ def title(self):
+ return 'Error raising Example'
+
+ def writeContent(self):
+ error = self.request().field('error', None)
+ if error:
+ msg = 'You clicked that button!'
+ if error.startswith('String'):
+ error = msg
+ elif error.startswith('System'):
+ error = SystemError(msg)
+ else:
+ error = StandardError(msg)
+ self.writeln('<p>About to raise an error...</p>')
+ raise error
+ self.writeln("""
+<h1>Error Test</h1>
+<form action="Error">
+<p><select name="error" size="1">
+<option selected>StandardError</option>
+<option>SystemError</option>
+<option>String error (old)</option>
+</select>
+<input type="submit" value="Don't click this button!"></p>
+</form>
+""")
|