mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
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:
parent
f58106c7b7
commit
60dfa38717
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user