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)