62247513862f

web: add nice error pages
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 10 Jul 2010 14:23:00 -0400
parents 9d8c2dd1ed72
children 6711e7217487
branches/tags (none)
files review/templates/404.html review/templates/500.html review/web.py

Changes

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/review/templates/404.html	Sat Jul 10 14:23:00 2010 -0400
@@ -0,0 +1,9 @@
+{% extends "base.html" %}
+
+{% block id %}404{% endblock %}
+{% block title %}Page not found - {% endblock %}
+
+{% block content %}
+    <h2>Page not found (404)</h2>
+    <p>The page you requested could not be found. <a href="/">Go home</a>.</p>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/review/templates/500.html	Sat Jul 10 14:23:00 2010 -0400
@@ -0,0 +1,13 @@
+{% extends "base.html" %}
+
+{% block id %}500{% endblock %}
+{% block title %}Server error - {% endblock %}
+
+{% block content %}
+    <h2>Server error (500)</h2>
+    <p>Something went horribly wrong.</p>
+    <p>
+        If you have a few extra minutes you could
+        <a href="http://bitbucket.org/sjl/hg-review/issues/">file a bug report</a>.
+    </p>
+{% endblock %}
--- a/review/web.py	Sat Jul 10 14:14:25 2010 -0400
+++ b/review/web.py	Sat Jul 10 14:23:00 2010 -0400
@@ -210,6 +210,14 @@
     return redirect('%s/' % app.site_root)
 
 
+@app.errorhandler(404)
+def page_not_found(error):
+    return _render('404.html'), 404
+
+@app.errorhandler(500)
+def server_error(error):
+    return _render('500.html'), 500
+
 def load_interface(ui, repo, read_only=False, allow_anon=False,
         open=False, address='127.0.0.1', port=8080):
     if open: