-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathError.py
35 lines (29 loc) · 995 Bytes
/
Error.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from .ExamplePage import ExamplePage
class CustomError(Exception):
pass
class Error(ExamplePage):
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('Custom'):
error = CustomError(msg)
elif error.startswith('System'):
error = SystemError(msg)
else:
error = RuntimeError(msg)
self.writeln('<p>About to raise an error...</p>')
raise error
self.writeln('''<h1>Error Test</h1>
<form action="Error" method="post">
<p><select name="error" size="1">
<option selected>Runtime Error</option>
<option>System Error</option>
<option>Custom Error</option>
</select>
<input type="submit" value="Don't click this button!"></p>
</form>''')