From 46cd109359acc743563c9d7efd210ab8f61c47c7 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 11 Apr 2023 00:26:25 +1000 Subject: [PATCH] Ignore validation errors when uploading to sentry.io (#4594) * Ignore validation errors when uploading to sentry.io * Don't actually return, silly! --- InvenTree/InvenTree/exceptions.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/InvenTree/InvenTree/exceptions.py b/InvenTree/InvenTree/exceptions.py index a7bcf9d39c..09fc4de192 100644 --- a/InvenTree/InvenTree/exceptions.py +++ b/InvenTree/InvenTree/exceptions.py @@ -64,7 +64,15 @@ def exception_handler(exc, context): if settings.SENTRY_ENABLED and settings.SENTRY_DSN and not settings.DEBUG: # Report this exception to sentry.io from sentry_sdk import capture_exception - capture_exception(exc) + + # 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) # Catch any django validation error, and re-throw a DRF validation error if isinstance(exc, DjangoValidationError):