Skip to content

Commit

Permalink
Expose TimeoutError during google_travel_time config_flow (#108179)
Browse files Browse the repository at this point in the history
Expose TimeoutError during config_flow
  • Loading branch information
eifinger committed Jan 19, 2024
1 parent cdf3c07 commit 384b22c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions homeassistant/components/google_travel_time/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ async def async_step_user(self, user_input=None) -> FlowResult:
)
except InvalidApiKeyException:
errors["base"] = "invalid_auth"
except TimeoutError:
errors["base"] = "timeout_connect"
except UnknownException:
errors["base"] = "cannot_connect"

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/google_travel_time/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def validate_config_entry(
raise UnknownException() from transport_error
except Timeout as timeout_error:
_LOGGER.error("Timeout error")
raise UnknownException() from timeout_error
raise TimeoutError() from timeout_error


class InvalidApiKeyException(Exception):
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/google_travel_time/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
},
"error": {
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"timeout_connect": "[%key:common::config_flow::error::timeout_connect%]"
},
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_location%]"
Expand Down
2 changes: 1 addition & 1 deletion tests/components/google_travel_time/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async def test_timeout(hass: HomeAssistant) -> None:
)

assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"}
assert result2["errors"] == {"base": "timeout_connect"}


async def test_malformed_api_key(hass: HomeAssistant) -> None:
Expand Down

0 comments on commit 384b22c

Please sign in to comment.