Skip to content

Commit

Permalink
feat-display-concise-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
EdLeckert committed Aug 26, 2023
1 parent 8c2f48d commit 9a765ee
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions custom_components/opensprinkler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from datetime import timedelta

import async_timeout
from aiohttp.client_exceptions import InvalidURL
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_URL
from homeassistant.core import HomeAssistant, ServiceCall
Expand Down Expand Up @@ -56,8 +57,14 @@ async def async_update_data():
async with async_timeout.timeout(TIMEOUT):
try:
await controller.refresh()
except Exception as exc:
raise UpdateFailed("Error fetching OpenSprinkler state") from exc
except InvalidURL as e:
_LOGGER.error(e)
except OpenSprinklerConnectionError as e:
_LOGGER.error(e)
except OpenSprinklerAuthError as e:
_LOGGER.error(e)
except Exception as e:
_LOGGER.exception(e)

if not controller._state:
raise UpdateFailed("Error fetching OpenSprinkler state")
Expand Down

0 comments on commit 9a765ee

Please sign in to comment.