[Django] #21536: the handler swallows exception

5 views
Skip to first unread message

Django

unread,
Nov 30, 2013, 4:48:49 AM11/30/13
to django-...@googlegroups.com
#21536: the handler swallows exception
--------------------------------------+--------------------
Reporter: wuhaochi@… | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Core (Other) | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
line /Library/Python/2.7/site-
packages/Django-1.6-py2.7.egg/django/core/handlers/base.py : 197.
the code is this:

{{{
except: # Handle everything else.
# Get the exception info now, in case another exception is
thrown later.
signals.got_request_exception.send(sender=self.__class__,
request=request)
response = self.handle_uncaught_exception(request, resolver,
sys.exc_info())
}}}

And this haunted me quite a while when I just made a syntax mistake in my
view function. Since I was reported "Server Error 500 27"
Internal Server error. But why?
When I add this block, I find the answer of my error.

{{{
except Exception as e:
import traceback
traceback.print_exc(e)

except: # Handle everything else.
# Get the exception info now, in case another exception is
thrown later.
signals.got_request_exception.send(sender=self.__class__,
request=request)
response = self.handle_uncaught_exception(request, resolver,
sys.exc_info())
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21536>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 5, 2013, 8:04:12 AM12/5/13
to django-...@googlegroups.com
#21536: the handler swallows exception
-------------------------------------+-------------------------------------
Reporter: wuhaochi@… | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version: 1.6
Component: Core (Other) | Resolution:
Severity: Normal | worksforme
Keywords: | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timo):

* status: new => closed
* needs_better_patch: => 0
* resolution: => worksforme
* needs_tests: => 0
* needs_docs: => 0


Comment:

It looks to me like you're requesting us to add logging for errors,
however, if you have logging properly setup, `handle_uncaught_exception()`
should log the error. If `DEBUG=True` you should get a colorful error
page.

--
Ticket URL: <https://code.djangoproject.com/ticket/21536#comment:1>

Reply all
Reply to author
Forward
0 new messages