diff --git a/custom_components/biketrax/coordinator.py b/custom_components/biketrax/coordinator.py index 6a7833b..350c856 100644 --- a/custom_components/biketrax/coordinator.py +++ b/custom_components/biketrax/coordinator.py @@ -4,7 +4,7 @@ import logging from datetime import timedelta -from aiobiketrax import Account +from aiobiketrax import Account, exceptions from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed @@ -49,8 +49,10 @@ async def _async_update_data(self) -> None: for device in self.account.devices: await device.update_position() - except (HTTPError, TimeoutException) as err: - raise UpdateFailed(f"Error communicating with BikeTrax API: {err}") from err + except exceptions.BikeTraxError as err: + raise UpdateFailed( + f"A BikeTrax error occurred while updating the devices: {err}" + ) from err def start_background_task(self): """Start the websocket task.""" @@ -83,8 +85,10 @@ async def _async_update_data(self) -> None: try: for device in self.account.devices: await device.update_trips() - except (HTTPError, TimeoutException) as err: - raise UpdateFailed(f"Error communicating with BikeTrax API: {err}") from err + except exceptions.BikeTraxError as err: + raise UpdateFailed( + f"A BikeTrax error occurred while updating the trips: {err}" + ) from err class SubscriptionDataUpdateCoordinator(BikeTraxDataUpdateCoordinator): @@ -109,5 +113,7 @@ async def _async_update_data(self) -> None: try: for device in self.account.devices: await device.update_subscription() - except (HTTPError, TimeoutException) as err: - raise UpdateFailed(f"Error communicating with BikeTrax API: {err}") from err + except exceptions.BikeTraxError as err: + raise UpdateFailed( + f"A BikeTrax error occurred while updating the subscription data: {err}" + ) from err