2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 21:15:41 +00:00

Exception handling (#5622)

* get_setting_object: Handle ProgrammingError

* Improved exception handling

- Address a few cases on application startup if the database is not ready (migrations not applied)
This commit is contained in:
Oliver
2023-09-27 13:42:20 +10:00
committed by GitHub
parent 2b0d81fd81
commit 08e7190832
4 changed files with 22 additions and 13 deletions

View File

@ -182,8 +182,11 @@ class LabelConfig(AppConfig):
shutil.copyfile(src_file, dst_file)
# Check if a label matching the template already exists
if model.objects.filter(label=filename).exists():
return # pragma: no cover
try:
if model.objects.filter(label=filename).exists():
return # pragma: no cover
except Exception:
logger.error(f"Failed to query label for '{filename}' - you should run 'invoke update' first!")
logger.info(f"Creating entry for {model} '{label['name']}'")