Closed WebSpider closed 2 months ago
Conflicts with #31, let's see how we can catch validationerrors in mashu
Conflicts with #31, let's see how we can catch validationerrors in mashu
We may not need to since mashu spits out failures like in skodaconnect/homeassistant-myskoda#34
In the meantime I had added this:
async def _make_get_request[T](self, url: str, deserialize: Callable[[str], T]) -> T:
async with self.session.get(
f"{BASE_URL_SKODA}/api{url}",
headers=await self._headers(),
) as response:
response_text = await response.text()
try:
data = deserialize(response_text)
except Exception:
_LOGGER.exception(
"Failed to load data from url %s. Return value was '%s'", url, response_text
)
raise
else:
return data
Which already wraps all get requests:
async def get_charging(self, vin: str) -> Charging:
"""Retrieve information related to charging for the specified vehicle."""
return await self._make_get_request(f"/v1/charging/{vin}", Charging.from_json)
Is this PR still needed?
If yes, can we find a more generic way?
I think we can close this. If we still need more/better logs it will bubble up again while looking at issues.
Fixes #22