mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-18 12:19:29 +00:00
Handle piston errors through Sentry
This commit is contained in:
19
app/api/resource.py
Normal file
19
app/api/resource.py
Normal 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)
|
||||
Reference in New Issue
Block a user