mirror of
https://github.com/inventree/InvenTree.git
synced 2026-08-19 19:49:48 +00:00
- Only log unhandled exceptions to sentry.io
- Check for valid handling first
- Report second
(cherry picked from commit 1020ed3009)
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
co-authored by
Oliver
parent
d9a5d96d8d
commit
7e206547a2
@@ -115,13 +115,6 @@ def exception_handler(exc, context):
|
||||
|
||||
response = None
|
||||
|
||||
# Pass exception to sentry.io handler
|
||||
try:
|
||||
InvenTree.sentry.report_exception(exc)
|
||||
except Exception:
|
||||
# If sentry.io fails, we don't want to crash the server!
|
||||
pass
|
||||
|
||||
# The Django app registry can be transiently un-ready while the plugin
|
||||
# registry is reloading apps (see plugin.registry.PluginsRegistry._reload_apps).
|
||||
# Any request handled by another thread/worker during that window can trip
|
||||
@@ -141,9 +134,17 @@ def exception_handler(exc, context):
|
||||
return response
|
||||
|
||||
# Catch any django validation error, and re-throw a DRF validation error
|
||||
if isinstance(exc, DjangoValidationError):
|
||||
elif isinstance(exc, DjangoValidationError):
|
||||
exc = DRFValidationError(detail=serializers.as_serializer_error(exc))
|
||||
|
||||
else:
|
||||
# Pass any other (unhandled) exception to sentry.io handler
|
||||
try:
|
||||
InvenTree.sentry.report_exception(exc)
|
||||
except Exception:
|
||||
# If sentry.io fails, we don't want to crash the server!
|
||||
pass
|
||||
|
||||
# Default to the built-in DRF exception handler
|
||||
response = drfviews.exception_handler(exc, context)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user