Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ekampf/sanic-sentry-error-handler
Sentry error handler for Sanic web server
https://github.com/ekampf/sanic-sentry-error-handler
python sanic sentry
Last synced: about 2 months ago
JSON representation
Sentry error handler for Sanic web server
- Host: GitHub
- URL: https://github.com/ekampf/sanic-sentry-error-handler
- Owner: ekampf
- License: mit
- Created: 2018-01-05T23:12:00.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-01T20:19:18.000Z (over 1 year ago)
- Last Synced: 2024-10-06T11:08:27.770Z (3 months ago)
- Topics: python, sanic, sentry
- Language: Python
- Homepage:
- Size: 27.3 KB
- Stars: 4
- Watchers: 5
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
sanic-sentry-error-handler
==========================
|Travis| |PyPI|Sentry error handler for Sanic web server
Requirements
------------- python >= 3.5
Installation
------------**sanic-sentry-error-handler** should be installed using pip: ::
pip install sanic-sentry-error-handler
Usage
-----
**SENTRY_DSN** - Sentry DSN for your applicationTo begin we'll set up a Sanic app:
.. code:: python
>>> from sanic import Sanic
>>> from sanic_sentry import SanicSentryErrorHandler
>>> app = Sanic(__name__)
>>> app.error_handler = SanicSentryErrorHandler('http://public:[email protected]/1')If your application uses the `Sanic exception handling views`_ you might consider using decorator for intercepting the exceptions.
.. code:: python
>>> from sanic import response, Sanic
>>> from sanic_sentry import SanicSentryErrorHandler
>>>
>>> sentry_client = SanicSentryErrorHandler('http://public:[email protected]/1')
>>> app = Sanic(__name__)
>>>
>>>
>>> @app.exception([Exception, ])
>>> @sentry_client.intercept_exception
>>> def handle_exception_500(request, exception):
>>> return response.json({"description": "Internal Server Error"}, status=500).. |Travis| image:: https://travis-ci.org/ekampf/sanic-sentry-error-handler.svg?branch=master
.. |PyPI| image:: https://badge.fury.io/py/sanic-sentry-error-handler.svg
:target: https://badge.fury.io/py/sanic-sentry-error-handler
.. _Sanic exception handling views: https://sanic.readthedocs.io/en/latest/sanic/exceptions.html#handling-exceptions