From aa34fe15b2addfc32fe6ba757e3eeb772cc384bd Mon Sep 17 00:00:00 2001 From: Josh Wright Date: Sat, 14 May 2016 20:46:49 -0400 Subject: [PATCH] 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. --- homeassistant/components/http.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/homeassistant/components/http.py b/homeassistant/components/http.py index 90cd6f2236b..81280352121 100644 --- a/homeassistant/components/http.py +++ b/homeassistant/components/http.py @@ -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