1
0
mirror of https://github.com/home-assistant/core.git synced 2026-07-18 12:03:33 +01:00

Include exception when reraising inside except (#109706)

This commit is contained in:
Marc Mueller
2024-02-06 12:17:39 +01:00
committed by GitHub
parent 6701806ed2
commit 5de76c0be0
7 changed files with 14 additions and 14 deletions
@@ -83,8 +83,8 @@ class ComelitBaseCoordinator(DataUpdateCoordinator[dict[str, Any]]):
return await self._async_update_system_data()
except (exceptions.CannotConnect, exceptions.CannotRetrieveData) as err:
raise UpdateFailed(repr(err)) from err
except exceptions.CannotAuthenticate:
raise ConfigEntryAuthFailed
except exceptions.CannotAuthenticate as err:
raise ConfigEntryAuthFailed from err
@abstractmethod
async def _async_update_system_data(self) -> dict[str, Any]:
@@ -106,9 +106,9 @@ async def test_host_connection(
try:
await hass.async_add_executor_job(lupupy.Lupusec, username, password, host)
except lupupy.LupusecException:
except lupupy.LupusecException as ex:
_LOGGER.error("Failed to connect to Lupusec device at %s", host)
raise CannotConnect
raise CannotConnect from ex
class CannotConnect(HomeAssistantError):
@@ -124,7 +124,7 @@ async def setup_device(
coordinator.api.is_available = True
try:
await coordinator.async_config_entry_first_refresh()
except ConfigEntryNotReady:
except ConfigEntryNotReady as ex:
if isinstance(coordinator.api, RoborockMqttClient):
_LOGGER.warning(
"Not setting up %s because the we failed to get data for the first time using the online client. "
@@ -136,7 +136,7 @@ async def setup_device(
# but in case if it isn't, the error can be included in debug logs for the user to grab.
if coordinator.last_exception:
_LOGGER.debug(coordinator.last_exception)
raise coordinator.last_exception
raise coordinator.last_exception from ex
elif coordinator.last_exception:
# If this is reached, we have verified that we can communicate with the Vacuum locally,
# so if there is an error here - it is not a communication issue but some other problem
@@ -147,7 +147,7 @@ async def setup_device(
device.name,
extra_error,
)
raise coordinator.last_exception
raise coordinator.last_exception from ex
return coordinator
@@ -28,8 +28,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if not client.check_credentials():
raise ConfigEntryError
return client
except PySuezError:
raise ConfigEntryNotReady
except PySuezError as ex:
raise ConfigEntryNotReady from ex
hass.data.setdefault(DOMAIN, {})[
entry.entry_id
@@ -40,8 +40,8 @@ def validate_input(data: dict[str, Any]) -> None:
)
if not client.check_credentials():
raise InvalidAuth
except PySuezError:
raise CannotConnect
except PySuezError as ex:
raise CannotConnect from ex
class SuezWaterConfigFlow(ConfigFlow, domain=DOMAIN):
+2 -2
View File
@@ -2202,8 +2202,8 @@ class FirmwareUploadView(HomeAssistantView):
node = async_get_node_from_device_id(hass, device_id, self._dev_reg)
except ValueError as err:
if "not loaded" in err.args[0]:
raise web_exceptions.HTTPBadRequest
raise web_exceptions.HTTPNotFound
raise web_exceptions.HTTPBadRequest from err
raise web_exceptions.HTTPNotFound from err
# If this was not true, we wouldn't have been able to get the node from the
# device ID above
+1 -1
View File
@@ -2249,7 +2249,7 @@ async def _load_integration(
domain,
err,
)
raise data_entry_flow.UnknownHandler
raise data_entry_flow.UnknownHandler from err
async def _async_get_flow_handler(