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
1 changed files with 12 additions and 0 deletions
|
@ -244,6 +244,18 @@ class HomeAssistantView(object):
|
|||
"""Initilalize the base view."""
|
||||
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
|
||||
# pylint: disable=invalid-name
|
||||
self.Response = Response
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue