mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Clean up Sonos unsubscribe/resubscribe exception handling and logging (#66025)
This commit is contained in:
parent
02cb879717
commit
715fe95abd
@ -399,12 +399,19 @@ class SonosSpeaker:
|
|||||||
return_exceptions=True,
|
return_exceptions=True,
|
||||||
)
|
)
|
||||||
for result in results:
|
for result in results:
|
||||||
if isinstance(result, Exception):
|
if isinstance(result, asyncio.exceptions.TimeoutError):
|
||||||
|
message = "Request timed out"
|
||||||
|
exc_info = None
|
||||||
|
elif isinstance(result, Exception):
|
||||||
|
message = result
|
||||||
|
exc_info = result if not str(result) else None
|
||||||
|
else:
|
||||||
|
continue
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Unsubscribe failed for %s: %s",
|
"Unsubscribe failed for %s: %s",
|
||||||
self.zone_name,
|
self.zone_name,
|
||||||
result,
|
message,
|
||||||
exc_info=result,
|
exc_info=exc_info,
|
||||||
)
|
)
|
||||||
self._subscriptions = []
|
self._subscriptions = []
|
||||||
|
|
||||||
@ -422,17 +429,16 @@ class SonosSpeaker:
|
|||||||
if not self.available:
|
if not self.available:
|
||||||
return
|
return
|
||||||
|
|
||||||
if getattr(exception, "status", None) == 412:
|
if isinstance(exception, asyncio.exceptions.TimeoutError):
|
||||||
_LOGGER.warning(
|
message = "Request timed out"
|
||||||
"Subscriptions for %s failed, speaker may have lost power",
|
exc_info = None
|
||||||
self.zone_name,
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
exc_info = exception if _LOGGER.isEnabledFor(logging.DEBUG) else None
|
message = exception
|
||||||
_LOGGER.error(
|
exc_info = exception if not str(exception) else None
|
||||||
"Subscription renewals for %s failed: %s",
|
_LOGGER.warning(
|
||||||
|
"Subscription renewals for %s failed, marking unavailable: %s",
|
||||||
self.zone_name,
|
self.zone_name,
|
||||||
exception,
|
message,
|
||||||
exc_info=exc_info,
|
exc_info=exc_info,
|
||||||
)
|
)
|
||||||
await self.async_offline()
|
await self.async_offline()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user