chiark / gitweb /
Introduce a `warn' output operation.
[chopwood] / cmd-cgi.py
index 104dd6afa9c43298cda12c0085d1cdbc01a450c2..f6bbe942b51a2d72c780f9b91c3338852e4dd907 100644 (file)
@@ -112,6 +112,17 @@ def cmd_fail_cgi(partial = False):
 <p>This is some normal output which will be rudely interrupted.""")
   raise Exception, 'You asked for this.'
 
+@CGI.subcommand(
+  'warn', ['cgi-noauth'],
+  'Raise an exception, to test the error reporting machinery.')
+def cmd_warn_cgi():
+  OUT.header(content_type = 'text/html')
+  OUT.warn("Here's a very important warning.")
+  CGI.format_tmpl(CGI.TMPL['wrapper.fhtml'],
+                  title = "Warning test", warnings = OUT.warnings,
+                  payload = "<h1>Chopwood: warning test</h1>\n"
+                  "<p>There ought to be a warning below.\n")
+
 ###--------------------------------------------------------------------------
 ### Static content.