Skip to content

Commit

Permalink
log invalid json payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
siku2 committed Sep 18, 2023
1 parent 87e9e2b commit 7c26886
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions custom_components/vzug/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,12 @@ async def once() -> Any:
_LOGGER.debug("raw response: %s", content)
return content

data = resp.json()
try:
data = resp.json()
except ValueError:
_LOGGER.debug("invalid json payload: %s", resp.text)
raise

_LOGGER.debug("data: %s", data)
if expected_type is list and data is None:
# if we want a list and the response is null, we just treat that as an empty list
Expand Down Expand Up @@ -565,7 +570,6 @@ async def get_eco_info(self, *, default_on_error: bool = False) -> EcoInfo:
)

async def get_device_info(self, *, default_on_error: bool = False) -> DeviceInfo:
# TODO: use this to replace a part of aggregations, display api version as a diagnostic sensor
# 'getAPIVersion' can be used to get only the API version
# 'getZHMode' gives just the zh mode
return await self._command(
Expand Down

0 comments on commit 7c26886

Please sign in to comment.