mirror of
https://github.com/django/django.git
synced 2025-12-19 07:12:25 +00:00
Fixed #616 -- Added a process_exception() hook to middleware framework. Thanks, Hugo
git-svn-id: http://code.djangoproject.com/svn/django/trunk@880 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
24154b2166
commit
a2e26150b7
3 changed files with 36 additions and 3 deletions
|
|
@ -16,7 +16,14 @@ def decorator_from_middleware(middleware_class):
|
|||
result = middleware.process_view(request, view_func, **kwargs)
|
||||
if result is not None:
|
||||
return result
|
||||
response = view_func(request, *args, **kwargs)
|
||||
try:
|
||||
response = view_func(request, *args, **kwargs)
|
||||
except Exception, e:
|
||||
if hasattr(middleware, 'process_exception'):
|
||||
result = middleware.process_exception(request, e)
|
||||
if result is not None:
|
||||
return result
|
||||
raise e
|
||||
if hasattr(middleware, 'process_response'):
|
||||
result = middleware.process_response(request, response)
|
||||
if result is not None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue