From a159f357ae9803dac53bf8721aaf9d4968d96f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 4 May 2025 14:18:35 +0300 Subject: [PATCH] Raise errors on action call problems --- .../components/huawei_lte/__init__.py | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/huawei_lte/__init__.py b/homeassistant/components/huawei_lte/__init__.py index be9d02e45fd..679bf677cf4 100644 --- a/homeassistant/components/huawei_lte/__init__.py +++ b/homeassistant/components/huawei_lte/__init__.py @@ -40,7 +40,11 @@ from homeassistant.const import ( Platform, ) from homeassistant.core import HomeAssistant, ServiceCall -from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady +from homeassistant.exceptions import ( + ConfigEntryAuthFailed, + ConfigEntryNotReady, + ServiceValidationError, +) from homeassistant.helpers import ( config_validation as cv, device_registry as dr, @@ -512,20 +516,15 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: (router for router in routers.values() if router.url == url), None ) elif not routers: - _LOGGER.error("%s: no routers configured", service.service) - return + raise ServiceValidationError("No routers configured") elif len(routers) == 1: router = next(iter(routers.values())) else: - _LOGGER.error( - "%s: more than one router configured, must specify one of URLs %s", - service.service, - sorted(router.url for router in routers.values()), + raise ServiceValidationError( + f"More than one router configured, must specify one of URLs {sorted(router.url for router in routers.values())}" ) - return if not router: - _LOGGER.error("%s: router %s unavailable", service.service, url) - return + raise ServiceValidationError(f"Router {url} not available") if service.service == SERVICE_RESUME_INTEGRATION: # Login will be handled automatically on demand @@ -536,7 +535,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: router.suspended = True _LOGGER.debug("%s: %s", service.service, "done") else: - _LOGGER.error("%s: unsupported service", service.service) + raise ServiceValidationError(f"Unsupported service {service.service}") for service in ADMIN_SERVICES: async_register_admin_service(