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
This commit is contained in:
Shantanu Tushar 2019-01-27 03:41:16 +05:30 committed by Paulus Schoutsen
parent 87316c4e83
commit a368db9ad4

View file

@ -81,7 +81,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
device = FireTVDevice(ftv, name, get_source, get_sources) device = FireTVDevice(ftv, name, get_source, get_sources)
add_entities([device]) 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): 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 an ADB command is already running, skip this command
if not self.adb_lock.acquire(blocking=False): if not self.adb_lock.acquire(blocking=False):
_LOGGER.info('Skipping an ADB command because a previous ' _LOGGER.info("Skipping an ADB command because a previous "
'command is still running') "command is still running")
return None return None
# Additional ADB commands will be prevented while trying this one # Additional ADB commands will be prevented while trying this one
try: try:
returns = func(self, *args, **kwargs) returns = func(self, *args, **kwargs)
except self.exceptions: except self.exceptions as err:
_LOGGER.error('Failed to execute an ADB command; will attempt ' _LOGGER.error(
'to re-establish the ADB connection in the next ' "Failed to execute an ADB command. ADB connection re-"
'update') "establishing attempt in the next update. Error: %s", err)
returns = None returns = None
self._available = False # pylint: disable=protected-access self._available = False # pylint: disable=protected-access
finally: finally:
@ -137,9 +137,9 @@ class FireTVDevice(MediaPlayerDevice):
self.adb_lock = threading.Lock() self.adb_lock = threading.Lock()
# ADB exceptions to catch # ADB exceptions to catch
self.exceptions = (AttributeError, BrokenPipeError, TypeError, self.exceptions = (
ValueError, InvalidChecksumError, AttributeError, BrokenPipeError, TypeError, ValueError,
InvalidCommandError, InvalidResponseError) InvalidChecksumError, InvalidCommandError, InvalidResponseError)
self._state = None self._state = None
self._available = self.firetv.available self._available = self.firetv.available
@ -231,8 +231,7 @@ class FireTVDevice(MediaPlayerDevice):
self._running_apps = None self._running_apps = None
# Check if the launcher is active. # Check if the launcher is active.
if self._current_app in [PACKAGE_LAUNCHER, if self._current_app in [PACKAGE_LAUNCHER, PACKAGE_SETTINGS]:
PACKAGE_SETTINGS]:
self._state = STATE_STANDBY self._state = STATE_STANDBY
# Check for a wake lock (device is playing). # Check for a wake lock (device is playing).