Skip to content

Commit

Permalink
UpdateFailedError log exception message rather than raising updatefai…
Browse files Browse the repository at this point in the history
…led error (#33)

add pyfuelprices as a logger (#33)
  • Loading branch information
pantherale0 authored Feb 3, 2025
1 parent 0e27c58 commit d7b97d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions custom_components/fuel_prices/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from homeassistant.core import HomeAssistant
from pyfuelprices import FuelPrices
from pyfuelprices.sources import UpdateFailedError
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed

_LOGGER = logging.getLogger(__name__)
Expand All @@ -31,8 +32,11 @@ async def _async_update_data(self):
async with async_timeout.timeout(240):
return await self.api.update()
except TimeoutError as err:
_LOGGER.error("Timeout updating fuel price data: %s", err)
_LOGGER.exception("Timeout updating fuel price data: %s", err)
except TypeError as err:
_LOGGER.error("Error updating fuel price data: %s", err)
_LOGGER.exception("Error updating fuel price data: %s", err)
except UpdateFailedError as err:
_LOGGER.exception(
"Error communicating with service (%s).", err.status, exc_info=err)
except Exception as err:
raise UpdateFailed(f"Error communicating with API {err}") from err
3 changes: 3 additions & 0 deletions custom_components/fuel_prices/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"integration_type": "service",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/pantherale0/ha-fuelprices/issues",
"loggers": [
"pyfuelprices"
],
"requirements": [
"xmltodict",
"brotli",
Expand Down

0 comments on commit d7b97d1

Please sign in to comment.