Skip to content

Commit

Permalink
Fail gracefully when no next draw available
Browse files Browse the repository at this point in the history
  • Loading branch information
inverse committed Jan 6, 2025
1 parent 8c2318a commit 004c0dc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion custom_components/premium_bond_checker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from premium_bond_checker.exceptions import PremiumBondCheckerException

from .const import (
CONF_HOLDER_NUMBER,
Expand Down Expand Up @@ -73,7 +74,13 @@ async def create_and_update_next_draw_coordinator(
"""Create and update a Premium Bond Next Draw coordinator."""
coordinator = PremiumBondNextDrawData(hass)
_LOGGER.debug("Requesting instance update")
await coordinator.async_config_entry_first_refresh()
try:
await coordinator.async_config_entry_first_refresh()
except PremiumBondCheckerException as e:
_LOGGER.error(
"Failed to fetch next draw date: %s",
e,
)

return coordinator

Expand Down

0 comments on commit 004c0dc

Please sign in to comment.