Skip to content

Commit

Permalink
Use custom exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Feb 12, 2023
1 parent 46b9429 commit 32d3d20
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions custom_components/integration_blueprint/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed

from .api import IntegrationBlueprintApiClient
from homeassistant.helpers.update_coordinator import (
DataUpdateCoordinator,
UpdateFailed,
)
from homeassistant.exceptions import ConfigEntryAuthFailed

from .api import (
IntegrationBlueprintApiClient,
IntegrationBlueprintApiClientAuthenticationError,
IntegrationBlueprintApiClientError,
)
from .const import DOMAIN, LOGGER


Expand All @@ -34,5 +42,7 @@ async def _async_update_data(self):
"""Update data via library."""
try:
return await self.client.async_get_data()
except Exception as exception:
raise UpdateFailed() from exception
except IntegrationBlueprintApiClientAuthenticationError as exception:
raise ConfigEntryAuthFailed(exception) from exception
except IntegrationBlueprintApiClientError as exception:
raise UpdateFailed(exception) from exception

0 comments on commit 32d3d20

Please sign in to comment.