2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-11-30 09:20:03 +00:00

Better handling of an invalid config file (#10857)

* Better handling of an invalid config file

* Remove dud line
This commit is contained in:
Oliver
2025-11-19 16:21:17 +11:00
committed by GitHub
parent a8f2a02d69
commit 18c2a934b8

View File

@@ -7,6 +7,7 @@ import os
import random
import shutil
import string
import sys
from pathlib import Path
from typing import Optional
@@ -195,7 +196,13 @@ def load_config_data(set_cache: bool = False) -> map | None:
cfg_file = get_config_file()
with open(cfg_file, encoding='utf-8') as cfg:
data = yaml.safe_load(cfg)
try:
data = yaml.safe_load(cfg)
except yaml.parser.ParserError as error:
logger.error(
"Error reading InvenTree configuration file '%s': %s", cfg_file, error
)
sys.exit(1)
# Set the cache if requested
if set_cache: