1
0
Fork 0

Wrap yaml parsing errors

This commit is contained in:
Maurizio Porrato 2023-08-04 08:43:52 +01:00
parent 5f08cff13b
commit 65226dba1a
1 changed files with 3 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import yaml
from yaml.composer import ComposerError
from operator_repo.exceptions import OperatorRepoException
from yaml.parser import ParserError
log = logging.getLogger(__name__)
@ -40,6 +41,8 @@ def _load_yaml_strict(path: Path) -> Any:
return yaml.safe_load(yaml_file)
except ComposerError:
raise OperatorRepoException(f"{path} contains multiple yaml documents")
except ParserError:
raise OperatorRepoException(f"{path} is not a valid yaml document")
def load_yaml(path: Path) -> Any: