Except and properly handle Errors in view decorator
authorSverre Rabbelier <srabbelier@gmail.com>
Mon, 09 Mar 2009 00:00:13 +0000
changeset 1761 cf39e8705fac
parent 1760 393891d794e2
child 1762 c47b9deb22ac
Except and properly handle Errors in view decorator After the next release we can remove all try/except combinations that are not customized and leave the handling of those exceptions to the view decorator. Patch by: Sverre Rabbelier
app/soc/views/helper/decorators.py
--- a/app/soc/views/helper/decorators.py	Sun Mar 08 23:58:27 2009 +0000
+++ b/app/soc/views/helper/decorators.py	Mon Mar 09 00:00:13 2009 +0000
@@ -47,6 +47,8 @@
   from soc.logic.helper import timeline
   from soc.logic.models.site import logic as site_logic
   from soc.logic.models.user import logic as user_logic
+  from soc.views import out_of_band
+  from soc.views.helper import responses
 
   @wraps(func)
   def view_wrapper(request, *args, **kwds):
@@ -73,6 +75,8 @@
     except AssertionError, exception:
       logging.exception(exception)
       return http.HttpResponseRedirect('/soc/content/assertion_error.html')
+    except out_of_band.Error, error:
+      return responses.errorResponse(error, request)
 
   return view_wrapper