mirror of
https://github.com/inventree/InvenTree.git
synced 2025-09-13 14:11:37 +00:00
Error tweaks (#10250)
* Refactor sentry checks * Refresh output from db before printing
This commit is contained in:
@@ -72,11 +72,22 @@ def report_exception(exc, scope: Optional[dict] = None):
|
||||
'report_exception should not be called in testing mode'
|
||||
)
|
||||
|
||||
if settings.SENTRY_ENABLED and settings.SENTRY_DSN:
|
||||
if not any(isinstance(exc, e) for e in sentry_ignore_errors()):
|
||||
logger.info('Reporting exception to sentry.io: %s', exc)
|
||||
# Skip if sentry not enabled, or not configured
|
||||
if not settings.SENTRY_ENABLED or not settings.SENTRY_DSN:
|
||||
return
|
||||
|
||||
try:
|
||||
sentry_sdk.capture_exception(exc, scope=scope)
|
||||
except Exception:
|
||||
logger.warning('Failed to report exception to sentry.io')
|
||||
# Skip if this error type is in the ignore list
|
||||
if any(isinstance(exc, e) for e in sentry_ignore_errors()):
|
||||
return
|
||||
|
||||
# Error may also be passed in from the loggingn context
|
||||
if hasattr(exc, 'event'):
|
||||
event = getattr(exc, 'event', None)
|
||||
|
||||
if any(isinstance(event, e) for e in sentry_ignore_errors()):
|
||||
return
|
||||
|
||||
try:
|
||||
sentry_sdk.capture_exception(exc, scope=scope)
|
||||
except Exception:
|
||||
logger.warning('Failed to report exception to sentry.io')
|
||||
|
@@ -207,6 +207,8 @@ class LabelPrint(GenericAPIView):
|
||||
output=None,
|
||||
)
|
||||
|
||||
output.refresh_from_db()
|
||||
|
||||
offload_task(
|
||||
report.tasks.print_labels,
|
||||
template.pk,
|
||||
|
Reference in New Issue
Block a user