mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 05:47:10 +00:00
Friendlier exceptions for misconfigured views
If a view is missing a url or name attribute, this will result in a more actionable exception being raised.
This commit is contained in:
parent
1096232e17
commit
aa34fe15b2
@ -244,6 +244,18 @@ class HomeAssistantView(object):
|
|||||||
"""Initilalize the base view."""
|
"""Initilalize the base view."""
|
||||||
from werkzeug.wrappers import Response
|
from werkzeug.wrappers import Response
|
||||||
|
|
||||||
|
if not hasattr(self, 'url'):
|
||||||
|
class_name = self.__class__.__name__
|
||||||
|
raise AttributeError(
|
||||||
|
'{0} missing required attribute "url"'.format(class_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
if not hasattr(self, 'name'):
|
||||||
|
class_name = self.__class__.__name__
|
||||||
|
raise AttributeError(
|
||||||
|
'{0} missing required attribute "name"'.format(class_name)
|
||||||
|
)
|
||||||
|
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
self.Response = Response
|
self.Response = Response
|
||||||
|
Loading…
x
Reference in New Issue
Block a user