Yaml errors no longer fail silently

This commit is contained in:
codemann8
2025-11-08 02:36:28 -06:00
parent a3dd82f467
commit 7016e5afbf
2 changed files with 39 additions and 30 deletions

View File

@@ -577,9 +577,13 @@ class CustomSettings(object):
def load_yaml(path):
if os.path.exists(Path(path)):
with open(path, "r", encoding="utf-8") as f:
return yaml.load(f, Loader=yaml.SafeLoader)
elif urllib.parse.urlparse(path).scheme in ['http', 'https']:
return yaml.load(urllib.request.urlopen(path), Loader=yaml.FullLoader)
try:
if os.path.exists(Path(path)):
with open(path, "r", encoding="utf-8") as f:
return yaml.load(f, Loader=yaml.SafeLoader)
elif urllib.parse.urlparse(path).scheme in ['http', 'https']:
return yaml.load(urllib.request.urlopen(path), Loader=yaml.FullLoader)
except yaml.YAMLError as e:
error_msg = f"Error parsing YAML file '{path}':\n{str(e)}"
raise ValueError(error_msg) from e