Improve incomfort coordinator logging (#135777)

This commit is contained in:
Jan Bouwhuis 2025-01-16 15:24:40 +01:00 committed by GitHub
parent 2e189480a5
commit 5ca68cb273
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 4 deletions

View File

@ -66,10 +66,10 @@ class InComfortDataCoordinator(DataUpdateCoordinator[InComfortData]):
for heater in self.incomfort_data.heaters:
await heater.update()
except TimeoutError as exc:
raise UpdateFailed from exc
raise UpdateFailed("Timeout error") from exc
except IncomfortError as exc:
if isinstance(exc.message, ClientResponseError):
if exc.message.status == 401:
raise ConfigEntryError("Incorrect credentials") from exc
raise UpdateFailed from exc
raise UpdateFailed(exc.message) from exc
return self.incomfort_data

View File

@ -3,7 +3,7 @@
from datetime import timedelta
from unittest.mock import MagicMock, patch
from aiohttp import ClientResponseError
from aiohttp import ClientResponseError, RequestInfo
from freezegun.api import FrozenDateTimeFactory
from incomfortclient import IncomfortError
import pytest
@ -63,7 +63,18 @@ async def test_coordinator_updates(
"exc",
[
IncomfortError(ClientResponseError(None, None, status=401)),
IncomfortError(ClientResponseError(None, None, status=500)),
IncomfortError(
ClientResponseError(
RequestInfo(
url="http://example.com",
method="GET",
headers=[],
real_url="http://example.com",
),
None,
status=500,
)
),
IncomfortError(ValueError("some_error")),
TimeoutError,
],