Better error handling (#11297)

* Better error handling

* Fixed hound
This commit is contained in:
Frantz authored and Pascal Vizeli committed 2017-12-25 17:46:42 +01:00
1 parent 802a95eac5
commit 14919082a3
2 files changed
+14 -8

No files matched your search

@@ -55,12 +55,15 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
password = config.get(CONF_PASSWORD)
port = config.get(CONF_PORT)
transmission_api = transmissionrpc.Client(
host, port=port, user=username, password=password)
try:
transmission_api = transmissionrpc.Client(
host, port=port, user=username, password=password)
transmission_api.session_stats()
except TransmissionError:
_LOGGER.exception("Connection to Transmission API failed")
except TransmissionError as error:
_LOGGER.error(
"Connection to Transmission API failed on %s:%s with message %s",
host, port, error.original
)
return False
# pylint: disable=global-statement
@@ -43,12 +43,15 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
password = config.get(CONF_PASSWORD)
port = config.get(CONF_PORT)
transmission_api = transmissionrpc.Client(
host, port=port, user=username, password=password)
try:
transmission_api = transmissionrpc.Client(
host, port=port, user=username, password=password)
transmission_api.session_stats()
except TransmissionError:
_LOGGING.error("Connection to Transmission API failed")
except TransmissionError as error:
_LOGGING.error(
"Connection to Transmission API failed on %s:%s with message %s",
host, port, error.original
)
return False
add_devices([TransmissionSwitch(transmission_api, name)])