2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-10-03 15:52:51 +00:00

Improved error handling (#10352)

- Closes https://github.com/inventree/InvenTree/issues/10338
This commit is contained in:
Oliver
2025-09-19 18:20:40 +10:00
committed by GitHub
parent 4b0acad518
commit f4333bd83f

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')