mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +00:00
Improved exception handling and logging (#22268)
Catch RuntimeError exceptions. Don't log ADB command output if there isn't any.
This commit is contained in:
parent
c90e13bfef
commit
b125514655
@ -163,7 +163,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
output = target_device.adb_command(cmd)
|
output = target_device.adb_command(cmd)
|
||||||
|
|
||||||
# log the output if there is any
|
# log the output if there is any
|
||||||
if output:
|
if output and (not isinstance(output, str) or output.strip()):
|
||||||
_LOGGER.info("Output of command '%s' from '%s': %s",
|
_LOGGER.info("Output of command '%s' from '%s': %s",
|
||||||
cmd, target_device.entity_id, repr(output))
|
cmd, target_device.entity_id, repr(output))
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ class ADBDevice(MediaPlayerDevice):
|
|||||||
TcpTimeoutException)
|
TcpTimeoutException)
|
||||||
else:
|
else:
|
||||||
# Using "pure-python-adb" (communicate with ADB server)
|
# Using "pure-python-adb" (communicate with ADB server)
|
||||||
self.exceptions = (ConnectionResetError,)
|
self.exceptions = (ConnectionResetError, RuntimeError)
|
||||||
|
|
||||||
# Property attributes
|
# Property attributes
|
||||||
self._available = self.aftv.available
|
self._available = self.aftv.available
|
||||||
|
Loading…
x
Reference in New Issue
Block a user