Handle piston errors through Sentry

This commit is contained in:
2011-05-31 16:25:32 +01:00
parent b28170df3e
commit 7200ab9571
3 changed files with 21 additions and 2 deletions

19
app/api/resource.py Normal file
View File

@@ -0,0 +1,19 @@
import sys
import logging
from sentry.client.handlers import SentryHandler
from piston.resource import Resource
class SentryResource(Resource):
def error_handler(self, e, request, meth, em_format):
print e
logger = logging.getLogger('piston')
logger.addHandler(SentryHandler())
logger.error('Piston exception: %s(%s)' % (e.__class__.__name__, e), exc_info=sys.exc_info(),
extra={'data': {'handler': meth.im_class, 'request': request, 'get': dict(request.GET), 'post': dict(request.POST) }})
return Resource.error_handler(self, e, request, meth, em_format)

View File

@@ -1,7 +1,7 @@
from django.conf.urls.defaults import *
from piston.resource import Resource
from piston.authentication import NoAuthentication
from api.resource import SentryResource as Resource
from api.auth import APIKeyAuthentication
from api.handlers import *

View File

@@ -1,6 +1,6 @@
MySQL-python
Django==1.3
django-piston==0.2.2
-e hg+https://bitbucket.org/jespern/django-piston@c4b2d21db51a#egg=django_piston
-e hg+https://bitbucket.org/ubernostrum/django-registration@d36a38202ee3#egg=django-registration
yolk==0.4.1
-e hg+http://bitbucket.org/schinckel/django-jsonfield#egg=django-jsonfield