Better error reporting remote classes

pull/244/head
Paulus Schoutsen 2015-07-26 00:14:55 -07:00
parent c659be7e17
commit fed36d2cd0
2 changed files with 11 additions and 6 deletions

View File

@ -119,7 +119,6 @@ _LOGGER = logging.getLogger(__name__)
def setup(hass, config=None):
""" Sets up the HTTP API and debug interface. """
if config is None or DOMAIN not in config:
config = {DOMAIN: {}}
@ -139,9 +138,14 @@ def setup(hass, config=None):
sessions_enabled = config[DOMAIN].get(CONF_SESSIONS_ENABLED, True)
server = HomeAssistantHTTPServer(
(server_host, server_port), RequestHandler, hass, api_password,
development, no_password_set, sessions_enabled)
try:
server = HomeAssistantHTTPServer(
(server_host, server_port), RequestHandler, hass, api_password,
development, no_password_set, sessions_enabled)
except OSError:
# Happens if address already in use
_LOGGER.exception("Error setting up HTTP server")
return False
hass.bus.listen_once(
ha.EVENT_HOMEASSISTANT_START,

View File

@ -120,8 +120,9 @@ class HomeAssistant(ha.HomeAssistant):
def start(self):
# Ensure a local API exists to connect with remote
if self.config.api is None:
bootstrap.setup_component(self, 'http')
bootstrap.setup_component(self, 'api')
if not bootstrap.setup_component(self, 'api'):
raise ha.HomeAssistantError(
'Unable to setup local API to receive events')
ha.Timer(self)