Skip to content

Commit a51ab4f

Browse files
committed
Added error for missing template file in FileTemplate
1 parent 4f43652 commit a51ab4f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

adafruit_templateengine.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,10 @@ def __init__(self, template_path: str, *, language: str = Language.HTML) -> None
831831
:param str template_path: Path to a file containing the template to be rendered
832832
:param str language: Language for autoescaping. Defaults to HTML
833833
"""
834+
835+
if not _exists_and_is_file(template_path):
836+
raise OSError(f"Template file not found: {template_path}")
837+
834838
with open(template_path, "rt", encoding="utf-8") as template_file:
835839
template_string = template_file.read()
836840
super().__init__(template_string, language=language)

0 commit comments

Comments
 (0)