← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/maas/fix-oops into lp:maas

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/fix-oops into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jtv/maas/fix-oops/+merge/91830

https://pastebin.canonical.com/59591/
-- 
https://code.launchpad.net/~jtv/maas/fix-oops/+merge/91830
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/fix-oops into lp:maas.
=== modified file 'src/maasserver/management/commands/runserver.py'
--- src/maasserver/management/commands/runserver.py	2012-01-24 12:44:48 +0000
+++ src/maasserver/management/commands/runserver.py	2012-02-07 13:46:32 +0000
@@ -21,6 +21,27 @@
     )
 
 
+error_template = """
+<html>
+<head><title>Oops! - %(id)s</title></head>
+<body>
+<h1>Oops!</h1>
+<p>
+  Something broke while generating this page.
+</p>
+<p>
+  If the problem persists, please
+  <a href="https://bugs.launchpad.net/maas/";>file a bug</a>.  Make a note of
+  the "oops id": <strong>%(id)s</strong>
+</html>
+""".lstrip()
+
+
+def render_error(report):
+    """Produce an HTML error report, in raw bytes (not unicode)."""
+    return (error_template % report).encode('ascii')
+
+
 class Command(BaseRunserverCommand):
     """Customized "runserver" command that wraps the WSGI handler."""
 
@@ -38,4 +59,4 @@
         oops_repository = DateDirRepo(settings.OOPS_REPOSITORY, 'maasserver')
         oops_config.publishers.append(oops_repository.publish)
         install_hooks(oops_config)
-        return make_app(wsgi_handler, oops_config)
+        return make_app(wsgi_handler, oops_config, error_render=render_error)