Skip to content

Instantly share code, notes, and snippets.

@buriy
Created May 15, 2009 19:45
Show Gist options
  • Save buriy/112398 to your computer and use it in GitHub Desktop.
Save buriy/112398 to your computer and use it in GitHub Desktop.
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