Skip to content

Commit

Permalink
Merge pull request #1 from mvdwetering/add_more_better_logging
Browse files Browse the repository at this point in the history
Add more better logging
  • Loading branch information
mvdwetering authored Apr 18, 2024
2 parents 3f8aff7 + 56db240 commit 4749711
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions aiohuesyncbox/errors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
"""Aiohuesyncbox errors."""

import logging

logger = logging.getLogger(__name__)


class AiohuesyncboxException(Exception):
"""Base error for aiohuesyncbox."""
Expand Down Expand Up @@ -36,4 +40,5 @@ class InvalidState(AiohuesyncboxException):

def raise_error(code: int, message: str) -> None:
cls = ERRORS.get(code, AiohuesyncboxException)
logger.debug("raise_error, %s, %s, %s", code, message, cls)
raise cls("{}: {}".format(code, message))
4 changes: 4 additions & 0 deletions aiohuesyncbox/huesyncbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ async def resolve(self, host, port=0, family=socket.AF_INET):
for host in hosts:
host["hostname"] = self._common_name

logger.debug("Resolved hosts: %s", hosts)

return hosts


Expand Down Expand Up @@ -230,10 +232,12 @@ async def request(
)
return data
except aiohttp.ClientError as err:
logger.debug(err, exc_info=True)
raise RequestError(
f"Error requesting data from {self._host}"
) from err
except asyncio.TimeoutError as err:
logger.debug(err, exc_info=True)
raise RequestError(
f"Timeout requesting data from {self._host}"
) from err
Expand Down

0 comments on commit 4749711

Please sign in to comment.