From 2eeeb9075a4972024954f1a2616e77e7ed84f68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ab=C3=ADlio=20Costa?= Date: Thu, 13 Jul 2017 16:01:12 +0100 Subject: [PATCH] Plex: Add exception handler when connection fails (#8179) * add exception handler when connection fails * plex: improve exception handling * remove uneeded exception handler --- homeassistant/components/media_player/plex.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/media_player/plex.py b/homeassistant/components/media_player/plex.py index a36eb08f851..f4c69ba1fe6 100644 --- a/homeassistant/components/media_player/plex.py +++ b/homeassistant/components/media_player/plex.py @@ -170,9 +170,9 @@ def setup_plexserver( except plexapi.exceptions.BadRequest: _LOGGER.exception("Error listing plex devices") return - except OSError: - _LOGGER.error("Could not connect to plex server at http://%s", - host) + except requests.exceptions.RequestException as ex: + _LOGGER.error("Could not connect to plex server at http://%s (%s)", + host, ex) return new_plex_clients = [] @@ -219,6 +219,10 @@ def setup_plexserver( except plexapi.exceptions.BadRequest: _LOGGER.exception("Error listing plex sessions") return + except requests.exceptions.RequestException as ex: + _LOGGER.error("Could not connect to plex server at http://%s (%s)", + host, ex) + return plex_sessions.clear() for session in sessions: