Ignore validation errors when uploading to sentry.io (#4594)

* Ignore validation errors when uploading to sentry.io

* Don't actually return, silly!
This commit is contained in:
Oliver 2023-04-11 00:26:25 +10:00 committed by GitHub
parent 0b6e2ee592
commit 46cd109359
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,6 +64,14 @@ def exception_handler(exc, context):
if settings.SENTRY_ENABLED and settings.SENTRY_DSN and not settings.DEBUG: if settings.SENTRY_ENABLED and settings.SENTRY_DSN and not settings.DEBUG:
# Report this exception to sentry.io # Report this exception to sentry.io
from sentry_sdk import capture_exception from sentry_sdk import capture_exception
# The following types of errors are ignored, they are "expected"
do_not_report = [
DjangoValidationError,
DRFValidationError,
]
if not any([isinstance(exc, err) for err in do_not_report]):
capture_exception(exc) capture_exception(exc)
# Catch any django validation error, and re-throw a DRF validation error # Catch any django validation error, and re-throw a DRF validation error