Redirect to an error page when a GAE exception occurs
authorSverre Rabbelier <srabbelier@gmail.com>
Sun, 01 Mar 2009 20:18:23 +0000
changeset 1582 f2f352ad193f
parent 1581 4484186d7427
child 1583 1e4c785f1adf
Redirect to an error page when a GAE exception occurs Patch by: Sverre Rabbelier
app/soc/content/assertion_error.html
app/soc/content/deadline_exceeded.html
app/soc/content/memory_error.html
app/soc/views/helper/decorators.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/content/assertion_error.html	Sun Mar 01 20:18:23 2009 +0000
@@ -0,0 +1,6 @@
+<html>
+<head><title>Something went wrong</title></head>
+<body>
+We ran into a problem while serving your request, please try again.
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/content/deadline_exceeded.html	Sun Mar 01 20:18:23 2009 +0000
@@ -0,0 +1,6 @@
+<html>
+<head><title>We ran out of time</title></head>
+<body>
+We ran out of processing time while serving your request, please try again.
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/content/memory_error.html	Sun Mar 01 20:18:23 2009 +0000
@@ -0,0 +1,6 @@
+<html>
+<head><title>We ran out of memory</title></head>
+<body>
+We ran out of memory while serving your request, please try again.
+</body>
+</html>
--- a/app/soc/views/helper/decorators.py	Sun Mar 01 20:00:54 2009 +0000
+++ b/app/soc/views/helper/decorators.py	Sun Mar 01 20:18:23 2009 +0000
@@ -45,15 +45,15 @@
   def view_wrapper(*args, **kwds):
     try:
       return func(*args, **kwds)
-    except DeadlineExceededError:
-      logging.exception('DeadlineExceededError')
-      return http.HttpResponse('DeadlineExceededError')
-    except MemoryError:
-      logging.exception('MemoryError')
-      return http.HttpResponse('MemoryError')
-    except AssertionError:
-      logging.exception('AssertionError')
-      return http.HttpResponse('AssertionError')
+    except DeadlineExceededError, e:
+      logging.exception(e)
+      return http.HttpResponseRedirect('/soc/content/deadline_exceeded.html')
+    except MemoryError, e:
+      logging.exception(e)
+      return http.HttpResponseRedirect('/soc/content/memory_error.html')
+    except AssertionError, e:
+      logging.exception(e)
+      return http.HttpResponseRedirect('/soc/content/assertion_error.html')
 
   return view_wrapper