Skip to content

Commit

Permalink
fix: ensure correct exception is raised
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Jun 10, 2024
1 parent d952acc commit 0d30b93
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions yalexs/manager/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ def _restore_live_attrs(
class YaleXSData(SubscriberMixin):
"""YaleXS Data coordinator object."""

def __init__(self, gateway: Gateway) -> None:
def __init__(
self, gateway: Gateway, error_exception_class: Exception = YaleXSError
) -> None:
"""Init August data object."""
super().__init__(MIN_TIME_BETWEEN_DETAIL_UPDATES)
self._gateway = gateway
Expand All @@ -73,6 +75,7 @@ def __init__(self, gateway: Gateway) -> None:
self._house_ids: set[str] = set()
self._pubnub_unsub: Callable[[], Coroutine[Any, Any, None]] | None = None
self._initial_sync_task: asyncio.Task | None = None
self._error_exception_class = error_exception_class

async def async_setup(self) -> None:
"""Async setup of august device data and activities."""
Expand Down Expand Up @@ -368,7 +371,7 @@ async def _async_call_api_op_requires_bridge(
device_name = self._get_device_name(device_id)
if device_name is None:
device_name = f"DeviceID: {device_id}"
raise YaleXSError(f"{device_name}: {err}") from err
raise self._error_exception_class(f"{device_name}: {err}") from err

return ret

Expand Down

0 comments on commit 0d30b93

Please sign in to comment.