Improve error handling. (#10482)

* Improve error handling.

* Fix import of core requirements.

* cleanup
pull/10494/head
cgtobi 2017-11-09 20:17:01 +01:00 committed by Pascal Vizeli
parent dd16b7cac3
commit 37eae7fb8a
1 changed files with 6 additions and 4 deletions

View File

@ -5,9 +5,9 @@ For more details about this component, please refer to the documentation at
https://home-assistant.io/components/influxdb/
"""
import logging
import re
import requests.exceptions
import voluptuous as vol
from homeassistant.const import (
@ -123,10 +123,12 @@ def setup(hass, config):
try:
influx = InfluxDBClient(**kwargs)
influx.query("SHOW SERIES LIMIT 1;", database=conf[CONF_DB_NAME])
except exceptions.InfluxDBClientError as exc:
except (exceptions.InfluxDBClientError,
requests.exceptions.ConnectionError) as exc:
_LOGGER.error("Database host is not accessible due to '%s', please "
"check your entries in the configuration file and that "
"the database exists and is READ/WRITE.", exc)
"check your entries in the configuration file (host, "
"port, etc.) and verify that the database exists and is "
"READ/WRITE.", exc)
return False
def influx_event_listener(event):