Skip to content

Instantly share code, notes, and snippets.

@matagus
Created December 15, 2011 02:58
Show Gist options
  • Save matagus/1479631 to your computer and use it in GitHub Desktop.
Save matagus/1479631 to your computer and use it in GitHub Desktop.
How to analyze rare exceptions in django/python projects by G. Dumpleton
from: http://groups.google.com/group/modwsgi/browse_thread/thread/f289c8167923aab7
The problem with Django is that there are certain circumstances where
it will hide the actual error message and traceback and replace it
will a higher level exception, but with the traceback then being where
that higher level exception was raised. This is one such case.
To try and find the real location of the exception add the following
to your WSGI script file.
import traceback
import sys
def dump_exception(callable):
def wrapper(*args, **kwargs):
try:
return callable(*args, **kwargs)
except:
traceback.print_exception(*sys.exc_info())
return wrapper
import django.core.urlresolvers
urlresolvers.get_callable = dump_exception(urlresolvers.get_callable)
This wraps the call which is doing the lookup and will dump out the
error message it raises before the traceback gets thrown away.
Please provide the resulting traceback as am quite curious to see it
and what it shows.
Graham
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment