Skip to content

Commit

Permalink
Added exceptions with debugging information for historical requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ldotlopez committed May 14, 2022
1 parent 8ae08f7 commit 20be91b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ideenergy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,20 @@ def _generation_parser(data) -> Dict[str, Any]:
)
resp = await self.raw_request("GET", url)
buff = await resp.content.read()
buff = buff.decode(resp.charset)
data = json.loads(buff)

return parser(data)
try:
buff = buff.decode(resp.charset)
data = json.loads(buff)

return parser(data)

except (TypeError, json.JSONDecodeError) as e:
raise InvalidData(buff) from e

except NotImplementedError as e:
raise NotImplementedError(
f"Request type not implemented: {req_type}. server data: {buff!r}"
) from e


class ClientError(Exception):
Expand Down

0 comments on commit 20be91b

Please sign in to comment.