Add error handling to !include command in yaml (#25801)
* Catch errors if !include file is not found * Address review comments * Add line number to error message
This commit is contained in:
1 parent
f58106c7b7
commit
60dfa38717
1 file changed
+4
-1
@@ -116,7 +116,10 @@ def _include_yaml(loader: SafeLineLoader, node: yaml.nodes.Node) -> JSON_TYPE:
|
||||
|
||||
"""
|
||||
fname = os.path.join(os.path.dirname(loader.name), node.value)
|
||||
return _add_reference(load_yaml(fname), loader, node)
|
||||
try:
|
||||
return _add_reference(load_yaml(fname), loader, node)
|
||||
except FileNotFoundError:
|
||||
raise HomeAssistantError(f"{node.start_mark}: Unable to read file {fname}.")
|
||||
|
||||
|
||||
def _is_file_valid(name: str) -> bool:
|
||||
|
||||
Reference in new issue
Block a user