mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-18 04:09: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)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from django.conf.urls.defaults import *
|
from django.conf.urls.defaults import *
|
||||||
from piston.resource import Resource
|
|
||||||
from piston.authentication import NoAuthentication
|
from piston.authentication import NoAuthentication
|
||||||
|
|
||||||
|
from api.resource import SentryResource as Resource
|
||||||
from api.auth import APIKeyAuthentication
|
from api.auth import APIKeyAuthentication
|
||||||
from api.handlers import *
|
from api.handlers import *
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
MySQL-python
|
MySQL-python
|
||||||
Django==1.3
|
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
|
-e hg+https://bitbucket.org/ubernostrum/django-registration@d36a38202ee3#egg=django-registration
|
||||||
yolk==0.4.1
|
yolk==0.4.1
|
||||||
-e hg+http://bitbucket.org/schinckel/django-jsonfield#egg=django-jsonfield
|
-e hg+http://bitbucket.org/schinckel/django-jsonfield#egg=django-jsonfield
|
||||||
|
|||||||
Reference in New Issue
Block a user