Django CrashKit Middleware

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
import crashkit
from django.conf import settings
crashkit.initialize_crashkit(*settings.CRASHKIT_ARGS)
class CrashKitSendException(object):
def process_exception(self, request, exception):
""" Load exceptions into CrashKit """
try:
env = {}
for key in request.META:
if key.startswith('HTTP_') or key.startswith('SERVER_') or key.startswith('REMOTE_'):
env[key] = request.META[key]
data = {'GET': dict(request.GET.iteritems()),
'POST': dict(request.POST.iteritems())}
crashkit.send_exception(data, env)
except Exception as e:
raise