Don't abort on unknown error in nina config flow (#127908)

This commit is contained in:
epenet 2024-10-08 09:10:26 +02:00 committed by GitHub
parent 6df77ef94b
commit 1eb8d0fa1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 6 deletions

View File

@ -116,7 +116,7 @@ class NinaConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except Exception as err: # noqa: BLE001
_LOGGER.exception("Unexpected exception: %s", err)
return self.async_abort(reason="unknown")
errors["base"] = "unknown"
self.regions = split_regions(self._all_region_codes_sorted, self.regions)
@ -199,7 +199,7 @@ class OptionsFlowHandler(OptionsFlow):
errors["base"] = "cannot_connect"
except Exception as err: # noqa: BLE001
_LOGGER.exception("Unexpected exception: %s", err)
return self.async_abort(reason="unknown")
errors["base"] = "unknown"
self.regions = split_regions(self._all_region_codes_sorted, self.regions)

View File

@ -38,10 +38,12 @@
}
}
},
"abort": {
"unknown": "[%key:common::config_flow::error::unknown%]"
},
"error": {
"no_selection": "[%key:component::nina::config::error::no_selection%]",
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"unknown": "[%key:common::config_flow::error::unknown%]"
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
}
}
}

View File

@ -89,7 +89,9 @@ async def test_step_user_unexpected_exception(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}, data=deepcopy(DUMMY_DATA)
)
assert result["type"] is FlowResultType.ABORT
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "unknown"}
hass.config_entries.flow.async_abort(result["flow_id"])
async def test_step_user(hass: HomeAssistant) -> None:
@ -300,7 +302,9 @@ async def test_options_flow_unexpected_exception(hass: HomeAssistant) -> None:
result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] is FlowResultType.ABORT
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "unknown"}
hass.config_entries.options.async_abort(result["flow_id"])
async def test_options_flow_entity_removal(