Redirect to an error page when a GAE exception occurs
Patch by: Sverre Rabbelier
--- /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