2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-11-13 19:36:46 +00:00

Improved error handling (#10352) (#10354)

- Closes https://github.com/inventree/InvenTree/issues/10338

(cherry picked from commit f4333bd83f)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
github-actions[bot]
2025-09-19 18:43:00 +10:00
committed by GitHub
parent 5ff7ce4703
commit 6207aa6c32

View File

@@ -4,7 +4,7 @@ import logging
import os
from django.apps import AppConfig
from django.core.exceptions import AppRegistryNotReady
from django.core.exceptions import AppRegistryNotReady, ValidationError
from django.core.files.base import ContentFile
from django.core.files.storage import default_storage
from django.db.utils import IntegrityError, OperationalError, ProgrammingError
@@ -52,6 +52,8 @@ class ReportConfig(AppConfig):
try:
self.create_default_labels()
self.create_default_reports()
except ValidationError:
logger.warning('Validation error when creating default templates')
except (
AppRegistryNotReady,
IntegrityError,
@@ -162,6 +164,10 @@ class ReportConfig(AppConfig):
**template, template=self.file_from_template('label', filename)
)
logger.info("Creating new label template: '%s'", template['name'])
except ValidationError:
logger.warning(
"Could not create label template: '%s'", template['name']
)
except Exception:
InvenTree.exceptions.log_error('create_default_labels', scope='init')
@@ -261,5 +267,9 @@ class ReportConfig(AppConfig):
**template, template=self.file_from_template('report', filename)
)
logger.info("Created new report template: '%s'", template['name'])
except ValidationError:
logger.warning(
"Could not create report template: '%s'", template['name']
)
except Exception:
InvenTree.exceptions.log_error('create_default_reports', scope='init')