This commit is contained in:
Jesse Bannon 2022-11-16 14:04:03 -08:00
parent 978dc36713
commit b88b4e507d

View file

@ -8,6 +8,9 @@ from yaml import YAMLError
from ytdl_sub.utils.exceptions import FileNotFoundException
from ytdl_sub.utils.exceptions import InvalidYamlException
from ytdl_sub.utils.logger import Logger
logger = Logger.get(name="yaml")
def load_yaml(file_path: str | Path) -> Dict:
@ -35,6 +38,7 @@ def load_yaml(file_path: str | Path) -> Dict:
with open(file_path, "r", encoding="utf-8") as file:
return yaml.safe_load(file)
except YAMLError as yaml_exception:
logger.debug(yaml_exception)
raise InvalidYamlException(
f"'{file_path}' has invalid YAML, copy-paste it into a YAML checker to find the issue."
) from yaml_exception