Created
May 15, 2009 19:45
-
-
Save buriy/112398 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SendExceptionMiddleware(object): | |
def process_exception(self, request, exception): | |
""" | |
Load exceptions into CrashKit | |
Credits to wiz | |
http://djangosnippets.org/snippets/1483/ | |
""" | |
try: | |
env = {} | |
for key in request.META: | |
if key.startswith('HTTP_') or key == 'SERVER_NAME' or key == 'SERVER_PORT' or key == 'REMOTE_ADDR' \ | |
or key == 'DOCUMENT_ROOT' or key.startswith('REQUEST_') or key.startswith('PATH_'): | |
env[key] = request.META[key] | |
data = {'GET': dict(request.GET.iteritems()), | |
'LANGUAGE': getattr(request, 'LANGUAGE_CODE', '-'), | |
'POST': dict(request.POST.iteritems())} | |
crashkit.send_exception(data, env) | |
except Exception: | |
raise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment