1 2 3 4 5 6 7 8 9 10 | from django.http import HttpResponseRedirect
class HttpMessageMiddleware(object):
def process_exception(self, request, exception):
if request.user.is_authenticated():
request.user.message_set.create(message=unicode(exception))
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
class HttpMessage(Exception):
pass
|
More like this
- Doing redirect without request by diverman 1 year, 4 months ago
- FixedEmailMessage by buriy 3 years, 11 months ago
- Severity codes in user messages by cconnell 3 years ago
- Super User Conditional Page Exception Reporting by zbyte64 3 years, 6 months ago
- Generic object_detail view with multiple named URL filters by cotton 1 month, 3 weeks ago
Comments
It can go in infinite loop. May be some query string parameter can be used to circumvent that.
#
This recipe catches all errors. "except HttpMessage" is missing in process_exception().
#