Ensure all template errors are caught and the websocket api reports them (#41719)

This commit is contained in:
J. Nick Koston 2020-10-12 09:38:24 -05:00 committed by GitHub
parent f7e7f1371e
commit b897ca7260
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 11 deletions

View file

@ -1,8 +1,6 @@
"""The exceptions used by Home Assistant."""
from typing import TYPE_CHECKING, Optional
import jinja2
if TYPE_CHECKING:
from .core import Context # noqa: F401 pylint: disable=unused-import
@ -22,7 +20,7 @@ class NoEntitySpecifiedError(HomeAssistantError):
class TemplateError(HomeAssistantError):
"""Error during template rendering."""
def __init__(self, exception: jinja2.TemplateError) -> None:
def __init__(self, exception: Exception) -> None:
"""Init the error."""
super().__init__(f"{exception.__class__.__name__}: {exception}")