Skip to content

Instantly share code, notes, and snippets.

@morenoh149
Last active January 17, 2023 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morenoh149/ff28d0397075e168ba596992e3ab5170 to your computer and use it in GitHub Desktop.
Save morenoh149/ff28d0397075e168ba596992e3ab5170 to your computer and use it in GitHub Desktop.
django ignore db errors in sentry
# sentry docs for filtering errors
# https://docs.sentry.io/platforms/python/guides/django/configuration/filtering/#event-hints
from django.urls import reverse_lazy
from django.db.utils import InterfaceError as djangoDbInterfaceError
...
def before_send(event, hint):
if 'exc_info' in hint:
exc_type, exc_value, tb = hint['exc_info']
if isinstance(exc_value, (ValidationError, djangoDbInterfaceError, )):
return None
return event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment