From a368db9ad40e14392552153d9df5f32d45c030f6 Mon Sep 17 00:00:00 2001 From: Shantanu Tushar Date: Sun, 27 Jan 2019 03:41:16 +0530 Subject: [PATCH] Include exception details in the error log (#20461) * Include exception details in the error log I see this error quite often in my HA logs and this will be helpful for anyone who is attempting to debug this. * Minor change * Remove line break --- .../components/media_player/firetv.py | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/media_player/firetv.py b/homeassistant/components/media_player/firetv.py index 80be58c04e1..c04ed96d6e0 100644 --- a/homeassistant/components/media_player/firetv.py +++ b/homeassistant/components/media_player/firetv.py @@ -81,7 +81,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): device = FireTVDevice(ftv, name, get_source, get_sources) add_entities([device]) - _LOGGER.info("Setup Fire TV at %s%s", host, adb_log) + _LOGGER.debug("Setup Fire TV at %s%s", host, adb_log) def adb_decorator(override_available=False): @@ -96,17 +96,17 @@ def adb_decorator(override_available=False): # If an ADB command is already running, skip this command if not self.adb_lock.acquire(blocking=False): - _LOGGER.info('Skipping an ADB command because a previous ' - 'command is still running') + _LOGGER.info("Skipping an ADB command because a previous " + "command is still running") return None # Additional ADB commands will be prevented while trying this one try: returns = func(self, *args, **kwargs) - except self.exceptions: - _LOGGER.error('Failed to execute an ADB command; will attempt ' - 'to re-establish the ADB connection in the next ' - 'update') + except self.exceptions as err: + _LOGGER.error( + "Failed to execute an ADB command. ADB connection re-" + "establishing attempt in the next update. Error: %s", err) returns = None self._available = False # pylint: disable=protected-access finally: @@ -137,9 +137,9 @@ class FireTVDevice(MediaPlayerDevice): self.adb_lock = threading.Lock() # ADB exceptions to catch - self.exceptions = (AttributeError, BrokenPipeError, TypeError, - ValueError, InvalidChecksumError, - InvalidCommandError, InvalidResponseError) + self.exceptions = ( + AttributeError, BrokenPipeError, TypeError, ValueError, + InvalidChecksumError, InvalidCommandError, InvalidResponseError) self._state = None self._available = self.firetv.available @@ -231,8 +231,7 @@ class FireTVDevice(MediaPlayerDevice): self._running_apps = None # Check if the launcher is active. - if self._current_app in [PACKAGE_LAUNCHER, - PACKAGE_SETTINGS]: + if self._current_app in [PACKAGE_LAUNCHER, PACKAGE_SETTINGS]: self._state = STATE_STANDBY # Check for a wake lock (device is playing).